Skip to content
Snippets Groups Projects
Commit 4b059fe4 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#89473

X-original-commit: acb980fd
Signed-off-by: default avatarWilliam Henrotin (whe) <whe@odoo.com>
Signed-off-by: default avatarWolfgang Taferner <w.taferner@wtioit.at>
parent cb47b70a
No related branches found
No related tags found
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.
Finish editing this message first!
Please register or to comment