[FIX] stock: quantity done compute

mismatch on the move lines used by the compute.

task-2241471
This commit is contained in:
Simon Lejeune
2020-06-15 16:59:40 +02:00
parent bd250eb18a
commit 02359fd78b
2 changed files with 7 additions and 2 deletions
+4 -2
View File
@@ -280,9 +280,11 @@ class StockMove(models.Model):
""" This will return the move lines to consider when applying _quantity_done_compute on a stock.move.
In some context, such as MRP, it is necessary to compute quantity_done on filtered sock.move.line."""
self.ensure_one()
return self.move_line_ids or self.move_line_nosuggest_ids
if self.picking_type_id.show_reserved is False:
return self.move_line_nosuggest_ids
return self.move_line_ids
@api.depends('move_line_ids.qty_done', 'move_line_ids.product_uom_id', 'move_line_nosuggest_ids.qty_done')
@api.depends('move_line_ids.qty_done', 'move_line_ids.product_uom_id', 'move_line_nosuggest_ids.qty_done', 'picking_type_id')
def _quantity_done_compute(self):
""" This field represents the sum of the move lines `qty_done`. It allows the user to know
if there is still work to do.
+3
View File
@@ -4369,6 +4369,7 @@ class StockMove(SavepointCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 2.0,
'picking_id': picking.id,
'picking_type_id': self.env.ref('stock.picking_type_out').id,
})
picking.action_confirm()
picking.action_assign()
@@ -4458,6 +4459,7 @@ class StockMove(SavepointCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 1.0,
'picking_id': picking.id,
'picking_type_id': self.env.ref('stock.picking_type_out').id,
})
move2 = self.env['stock.move'].create({
'name': 'test_transit_2',
@@ -4467,6 +4469,7 @@ class StockMove(SavepointCase):
'product_uom': self.uom_unit.id,
'product_uom_qty': 2.0,
'picking_id': picking.id,
'picking_type_id': self.env.ref('stock.picking_type_out').id,
})
picking.action_confirm()
picking.action_assign()