From 8b8eca55c6c71ad3710dff19e57e0f0fe606539d Mon Sep 17 00:00:00 2001 From: "Ahmed Khalaf (ahkh)" Date: Wed, 3 Aug 2022 12:26:29 +0000 Subject: [PATCH] [FIX] stock_picking_batch: add picks to batch When adding list of transfers to batch from transfer tree view, if transfers belong to two or more batches an error traceback pops. To reproduce: 1-Create Transfer 1, go to Transfer list view and add it to batch under Action, choose add to a new batch transfer and confirm. 2-Create Transfer 2 and do the same. 3-Now that we have two transfer belonging to two different batches, Under Inventory->Operations->Transfers, select the two transfers in the tree view and choose add to batch under Action, choose add to new batch and confirm, error popsup Bug originated from: #89815 Discovered while working on TaskId:2871679 closes odoo/odoo#97998 X-original-commit: 82580b0ba9dbbfb244ede233a251b059e2c233ba Signed-off-by: William Henrotin (whe) Signed-off-by: Ahmed Khalaf --- addons/stock_picking_batch/models/stock_picking_batch.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/stock_picking_batch/models/stock_picking_batch.py b/addons/stock_picking_batch/models/stock_picking_batch.py index a044a986b92..5c69ac0b8b2 100644 --- a/addons/stock_picking_batch/models/stock_picking_batch.py +++ b/addons/stock_picking_batch/models/stock_picking_batch.py @@ -166,8 +166,8 @@ class StockPickingBatch(models.Model): def write(self, vals): res = super().write(vals) - if not self.picking_ids and self.state == 'in_progress': - self.action_cancel() + if not self.picking_ids: + self.filtered(lambda b: b.state == 'in_progress').action_cancel() if vals.get('picking_type_id'): self._sanity_check() if vals.get('picking_ids'):