From 4468d186152986c02ec063a7ffb60085bd578f91 Mon Sep 17 00:00:00 2001 From: clesgow Date: Tue, 3 May 2022 14:01:15 +0000 Subject: [PATCH] [FIX] stock_picking_batch: fix cancel in batch As done with the "done" state, if a single picking in a batch is cancelled while the other pickings aren't, this picking is removed from the batch, as it would create inconsistencies between the states of the pickings in a single batch. closes odoo/odoo#90449 X-original-commit: 1f2813e59970cd2eb078b514cd7d563837f175a1 Signed-off-by: Arnold Moyaux Signed-off-by: Quentin Wolfs (quwo) --- addons/stock_picking_batch/models/stock_picking.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/addons/stock_picking_batch/models/stock_picking.py b/addons/stock_picking_batch/models/stock_picking.py index 615428de098..b9fb974e40f 100644 --- a/addons/stock_picking_batch/models/stock_picking.py +++ b/addons/stock_picking_batch/models/stock_picking.py @@ -127,6 +127,13 @@ class StockPicking(models.Model): return res + def action_cancel(self): + res = super().action_cancel() + for picking in self: + if picking.batch_id and any(picking.state != 'cancel' 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