From f7290fc9fed14152cec207efe968f5d2ae17c69c Mon Sep 17 00:00:00 2001 From: Arnold Moyaux Date: Mon, 13 Sep 2021 12:49:15 +0000 Subject: [PATCH] [FIX] stock: duplicate picking on push rules Usecase: - 2 warehouses 1 and 2 - Create a route with a rule from inter-warehouse to WH2 - Create a picking type for WH1 for stock to inter-warehouse - Create a planned transfer with 2 stock.move in the wH1 new picking type -* Go back to inventory overview - Click on process on the picking type WH1 -> inter-warehouse -* Process the picking created before - Go to WH2 delivery You see 2 pickings for each stock.move despite they share the same data (procurement group, source and dest locations) If you don't do the steps bewteen *, you only have 1 picking. It's due to the context of the views that is propagate to the new picking created by push rules. opw-2533718 closes odoo/odoo#76821 X-original-commit: 60c7722eedc1835a8aca9d6bbd75f5ab66ea4b59 Signed-off-by: Arnold Moyaux --- addons/stock/models/stock_move.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py index 56f0747140b..924e9e55697 100644 --- a/addons/stock/models/stock_move.py +++ b/addons/stock/models/stock_move.py @@ -11,7 +11,7 @@ from odoo import _, api, fields, models from odoo.exceptions import UserError from odoo.osv import expression from odoo.tools.float_utils import float_compare, float_is_zero, float_round -from odoo.tools.misc import OrderedSet +from odoo.tools.misc import clean_context, OrderedSet PROCUREMENT_PRIORITIES = [('0', 'Normal'), ('1', 'Urgent')] @@ -1175,7 +1175,7 @@ class StockMove(models.Model): # assign picking in batch for all confirmed move that share the same details for moves_ids in to_assign.values(): - self.browse(moves_ids)._assign_picking() + self.browse(moves_ids).with_context(clean_context(self.env.context))._assign_picking() new_push_moves = self.filtered(lambda m: not m.picking_id.immediate_transfer)._push_apply() self._check_company() moves = self