[FIX] stock_picking_batch: Fix batched pickings validation
If a picking is in a batch, the point is to process it as a whole. Yet, it is possible to validate a single picking (putting it in a 'done' state), inside of an 'in_progress' batch. This raises inconsistencies between the state of the batch as a whole and the state of some of it pickings. Therefore, when a single batched picking is validated in a batch that still contains other non-done pickings, the picking is removed from the batch. closes odoo/odoo#85324 X-original-commit: e9602d6b28331f68a83b5ce8a06a2ffc8ac3453d Signed-off-by: Arnold Moyaux <arm@odoo.com> Signed-off-by: Quentin Wolfs (quwo) <quwo@odoo.com>
This commit is contained in:
@@ -119,6 +119,14 @@ class StockPicking(models.Model):
|
||||
picking._find_auto_batch()
|
||||
return res
|
||||
|
||||
def _action_done(self):
|
||||
res = super()._action_done()
|
||||
for picking in self:
|
||||
if picking.batch_id and any(picking.state != 'done' for picking in picking.batch_id.picking_ids):
|
||||
picking.batch_id = None
|
||||
|
||||
return res
|
||||
|
||||
def _should_show_transfers(self):
|
||||
if len(self.batch_id) == 1 and self == self.batch_id.picking_ids:
|
||||
return False
|
||||
|
||||
@@ -449,3 +449,8 @@ class TestBatchPicking(TransactionCase):
|
||||
self.assertTrue(picking_out_3.batch_id)
|
||||
self.assertEqual(picking_out_1.batch_id.id, picking_out_3.batch_id.id)
|
||||
self.assertFalse(picking_out_2.batch_id)
|
||||
# If Picking 1 is validated without Picking 3, Picking 1 should be removed from the batch
|
||||
picking_out_1.move_ids.quantity_done = 10
|
||||
picking_out_1.button_validate()
|
||||
self.assertFalse(picking_out_1.batch_id)
|
||||
self.assertEqual(len(picking_out_3.batch_id.picking_ids), 1)
|
||||
|
||||
Reference in New Issue
Block a user