Skip to content
Snippets Groups Projects
Commit acb980fd authored by Wolfgang Taferner's avatar Wolfgang Taferner
Browse files

[FIX] mrp: done qty were missed to be taken into consideration


for qty changed finished product moves which would create negative moves
for closed production orders and therefore messing up forecasted quantities
without the possibility for a normal user to cleanup (delete or cancel)

closes odoo/odoo#86160

Signed-off-by: default avatarWilliam Henrotin (whe) <whe@odoo.com>
parent 7dd5437a
Branches
Tags
No related merge requests found
......@@ -36,9 +36,19 @@ class ChangeProductionQty(models.TransientModel):
for move in production.move_finished_ids:
if move.state in ('done', 'cancel'):
continue
qty = (new_qty - old_qty) * move.unit_factor
done_qty = sum(production.move_finished_ids.filtered(
lambda r:
r.product_id == move.product_id and
r.state == 'done'
).mapped('product_uom_qty')
)
qty = (new_qty - old_qty) * move.unit_factor + done_qty
modification[move] = (move.product_uom_qty + qty, move.product_uom_qty)
move.write({'product_uom_qty': move.product_uom_qty + qty})
if (move.product_uom_qty + qty) > 0:
move.write({'product_uom_qty': move.product_uom_qty + qty})
else:
move._action_cancel()
return modification
def change_prod_qty(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment