-
-
Notifications
You must be signed in to change notification settings - Fork 790
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
[14.0'][ADD] Add purchase_propagate_qty_mrp #2449
base: 14.0
Are you sure you want to change the base?
Conversation
b3ea1b0
to
98973f7
Compare
|
||
def _propagate_qty_to_moves_mrp(self): | ||
self.ensure_one() | ||
bom = self.env["mrp.bom"].sudo()._bom_find(product=self.product_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes _bom_find should be used but at first the moves should be checked.
If there is no move with a bom line which linked to a bom for the purchased product than _bom_find should be used.
This is the case for a kits in kit scenario then there is no bom for the main product.
bom = self.env["mrp.bom"].sudo()._bom_find(product=self.product_id) | |
boms = self.move_ids.bom_line_id.bom_id | |
relevant_bom = False | |
for bom in boms: | |
if bom.type == "phantom" and (bom.product_id == self.product_id or bom.product_tmpl_id == self.product_id.product_tmpl_id and not bom.product_id): | |
relevant_bom = bom | |
break | |
if not relevant_bom: | |
relevant_bom = self.env["mrp.bom"].sudo()._bom_find(product=self.product_id, bom_type="phantom") | |
bom = relevant_bom |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your review. Using the bom_line_id
on stock.move to find the related bom sounds much better.
Do you think using _bom_find
is still necessary, because anyway no matching will be possible between the stock.move and the bom.line from the explode.
I will not include it yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it is still necessary for a kit in kit scenario.
For example:
P-Kit-1 -> includes P1 and P2
P-Kit-2 -> includes P3 and P4
P-Kit-3 -> includes P-Kit-1 and P-Kit-2
The you will end update with moves for P1, P2, P3 and P4 no move will be link to the bom of P-Kit-3, the will be linked to P-Kit-1 bomlines and P-Kit-2. You will never find a bom for P-Kit-3.
bom_line_data["qty"], quant_uom | ||
) | ||
moves = self.move_ids.filtered( | ||
lambda move: move.product_id == bom_line.product_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lambda move: move.product_id == bom_line.product_id | |
lambda move: move.bom_line_id == bom_line |
98973f7
to
d8e06d3
Compare
No description provided.