Skip to content

Commit

Permalink
[FIX] mrp: prevent byproduct missing record error
Browse files Browse the repository at this point in the history
Before this commit, there was a bug with MO by-product moves:

     - With a newly created MO, confirm MO and after manually add `Produced`
       quantity in By-Products and change quantity producing in MO and  save the
       record then it raises the missing record error.

same issues was fixed here c1768d0
but forgot to fix same in write method.
so this commit is fix same but in write method

TaskID - 2799848

closes #92728

Signed-off-by: Tiffany Chang <tic@odoo.com>
  • Loading branch information
kado-odoo committed Jun 28, 2022
1 parent f95076f commit 9d3d0d0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions addons/mrp/models/mrp_production.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,9 @@ def _check_production_lines(self):
raise ValidationError(_("The component %s should not be the same as the product to produce.") % production.product_id.display_name)

def write(self, vals):
if 'move_byproduct_ids' in vals and 'move_finished_ids' not in vals:
vals['move_finished_ids'] = vals['move_byproduct_ids']
del vals['move_byproduct_ids']
if 'workorder_ids' in self:
production_to_replan = self.filtered(lambda p: p.is_planned)
res = super(MrpProduction, self).write(vals)
Expand Down
1 change: 1 addition & 0 deletions addons/mrp/tests/test_byproduct.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def test_00_mrp_byproduct(self):
# I consume and produce the production of products.
# I create record for selecting mode and quantity of products to produce.
mo_form = Form(mnf_product_a)
mnf_product_a.move_byproduct_ids.quantity_done = 2
mo_form.qty_producing = 2.00
mnf_product_a = mo_form.save()
# I finish the production order.
Expand Down

0 comments on commit 9d3d0d0

Please sign in to comment.