[FIX] mrp: detailed operations popup results in infinite recursion

To reproduce:
- Create and confirm MO with a tracked component (qty 1, in stock)
- Open the shop floor app and click on the move line for the component
- In the pop-up, change the quantity to 2 and click save

Current behavior:
Crash on an infinite recursion.
The issue was introduced in [1], as setting picked to True in the
stock.move write triggers another call to write on the stock.move,
resulting in the infinite recursion.

Expected behavior when this PR is merged:
The quantity on the stock.move is updated, and the popup closes.
By just updating the vals of the write, we do not trigger the write
method again and avoid the recursion while still maintaining the wanted
functionality from [1].

[1] https://github.com/odoo/odoo/commit/fe508c6b2cb1b92d7b063cc194a3dad37f4eb255

closes odoo/odoo#145922

Signed-off-by: Tiffany Chang (tic) <tic@odoo.com>
This commit is contained in:
Pieter Claeys (clpi)
2023-12-13 10:20:43 +00:00
parent 3ac60430c7
commit bdf16d51d7
+1 -1
View File
@@ -288,7 +288,7 @@ class StockMove(models.Model):
if self.env.context.get('force_manual_consumption'):
vals['manual_consumption'] = True
if vals.get('manual_consumption'):
self.picked = True
vals['picked'] = True
if 'product_uom_qty' in vals and 'move_line_ids' in vals:
# first update lines then product_uom_qty as the later will unreserve
# so possibly unlink lines