Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.0][MIG] mrp_auto_assign #270

Merged
merged 3 commits into from
Jul 2, 2018

Conversation

LoisRForgeFlow
Copy link
Contributor

Migration to v11.

cc @florian-dacosta

@LoisRForgeFlow LoisRForgeFlow force-pushed the 11.0-mig-mrp_auto_assign branch 3 times, most recently from 022ecc4 to ed050d4 Compare May 2, 2018 09:29
@LoisRForgeFlow LoisRForgeFlow mentioned this pull request May 2, 2018
25 tasks
@LoisRForgeFlow LoisRForgeFlow force-pushed the 11.0-mig-mrp_auto_assign branch from ed050d4 to efc7891 Compare May 2, 2018 11:09
@LoisRForgeFlow
Copy link
Contributor Author

I identified a problem with the module mrp_mto_with_stock while migrating this one so I fixed the issue here: 6f2a889

@LoisRForgeFlow LoisRForgeFlow added this to the 11.0 milestone May 2, 2018

from odoo import api, models
import logging
_logger = logging.getLogger(__name__)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useless import

if qty_to_procure < move.product_uom_qty:
move.product_uom_qty - move.reserved_availability -
sum(move.mapped('move_orig_ids.product_uom_qty')))
if 0.0 < qty_to_procure < move.product_uom_qty:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the problem. It would be nice to add a test to show the problem, so we avoid a regression on next migration.

But I don't think this change fixes the problem fully. For instance, if the raw material is purchased instead of manufactured, the system will create a draft PO instead of a MO. In this case, and until the PO is validated, the move.mapped('move_orig_ids.product_uom_qty') will always be 0 (because the incoming shipment is not yet created) and the bug will still happen.

IMHO, after creating the raw material MO or PO, we should :

  1. write procure_method = 'make_to_order' on the raw material stock move that need the sub MO/PO
  2. Recompute its state so it become 'waiting' (method _recompute_state)
    This way, we have the same data as if the raw material product is configured with route make to order.

Then we can add the procure_method field in the condition :

if move.state in ('partially_available', 'confirmed') \
                         and move.location_id in \
                         move.product_id.mrp_mts_mto_location_ids \
                         and not mto_with_no_move_dest_id and move.procure_method != 'make_to_order':

This way, a raw material move that has already generated a sub MO/PO won't be taken into account anymore and it works for the purchase raw material case.

Indeed, with the present way, what I don't like is that the raw material moves states and procurement method are not coherent with what really happen. (When a stock move waits another move, it has to be in waiting state, not confirmed

For the second case (mto_with_no_move_dest_id checked) I don't think there is any problem. I guess we could also put move.procure_method != 'make_to_order' in the main condition. But for this case, we should not write the procure_method to make_to_order, as there are no link between the sub MOs/POs and the main.

What do you think?
Do you know if the bug is also present in version 10?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, the issue will still be persistent with POs. I like your approach, to actually manage them as make_to_order it's indeed a improvement , the problem is odoo does allow a easy modification to the procure_method, see.

I will try to play around it and extend the tests.

No, the bug is not present in v10 as there were procurement.orders.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@florian-dacosta I think it should be good now. I saw that what I did finally was what you were saying on the first place, I guess I misunderstood you a little bit on my previous comment. Anyway, it is ready now!

Copy link
Contributor

@florian-dacosta florian-dacosta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test + code review 👍
Thanks a lot @lreficent

It would be nice to merge this fast as the bug is quite serious. @bodedra @jbeficent @guewen @max3903

@LoisRForgeFlow LoisRForgeFlow force-pushed the 11.0-mig-mrp_auto_assign branch 2 times, most recently from 23b2073 to ee72a52 Compare May 3, 2018 12:29
@bodedra
Copy link
Member

bodedra commented May 9, 2018

May you review minor improvement at ForgeFlow#4

@LoisRForgeFlow
Copy link
Contributor Author

Hi @bodedra @florian-dacosta

I've made a rework of mrp_mto_with_stock module here: #278

The fix done here it's not the good one I think. Can you please review?

@florian-dacosta
Copy link
Contributor

Since maybe the fix on mrp_mto_with_stock of this PR won't be applied (if the PR 278 is accepted), can you split this PR in order to only let the mrp_auto_assign migration?

@LoisRForgeFlow LoisRForgeFlow force-pushed the 11.0-mig-mrp_auto_assign branch from ee72a52 to 5d3c959 Compare June 13, 2018 09:08
@LoisRForgeFlow
Copy link
Contributor Author

@florian-dacosta yes, done!

@florian-dacosta
Copy link
Contributor

Thanks!
👍

@LoisRForgeFlow LoisRForgeFlow force-pushed the 11.0-mig-mrp_auto_assign branch from 5d3c959 to 14519df Compare June 20, 2018 09:06
@LoisRForgeFlow
Copy link
Contributor Author

Rebased and 🍏 !

@JordiBForgeFlow JordiBForgeFlow merged commit 25cf793 into OCA:11.0 Jul 2, 2018
@MiquelRForgeFlow MiquelRForgeFlow deleted the 11.0-mig-mrp_auto_assign branch July 2, 2018 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants