[FIX] stock: compute quantity_done in onchange
When computing `quantity_done` in an onchange, `move.id` is a `NewId`, not an `int`. However, the `read_group` call returns regular integers for `move_id`. Consequently, `rec.get(move.id, [])` is an empty list. closes odoo/odoo#49495 X-original-commit: 2ce1ed31a9c1ec7a7467983a040e4a056f8f4e69 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
@@ -306,11 +306,13 @@ class StockMove(models.Model):
|
||||
for d in data:
|
||||
rec[d['move_id'][0]] += [(d['product_uom_id'][0], d['qty_done'])]
|
||||
|
||||
# In case we are in an onchange, move.id is a NewId, not an integer. Therefore, there is no
|
||||
# match in the rec dictionary. By using move.ids[0] we get the correct integer value.
|
||||
for move in self:
|
||||
uom = move.product_uom
|
||||
move.quantity_done = sum(
|
||||
self.env['uom.uom'].browse(line_uom_id)._compute_quantity(qty, uom, round=False)
|
||||
for line_uom_id, qty in rec.get(move.id, [])
|
||||
for line_uom_id, qty in rec.get(move.ids[0] if move.ids else move.id, [])
|
||||
)
|
||||
|
||||
def _quantity_done_set(self):
|
||||
|
||||
Reference in New Issue
Block a user