From 066bfbb2a48190eb9a6561d8dda26a58c75a0175 Mon Sep 17 00:00:00 2001 From: Mike Date: Tue, 11 Jun 2024 00:01:30 +0200 Subject: [PATCH] [FIX] stock_intercompany_bidirectional: counterpart picking destination location set as the operation type default destination location set in settings [FIX] stock_intercompany: pre-commit fix --- stock_intercompany/models/stock_picking.py | 3 ++- stock_intercompany_bidirectional/models/stock_picking.py | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/stock_intercompany/models/stock_picking.py b/stock_intercompany/models/stock_picking.py index 9c407de3856..936bd9224b1 100644 --- a/stock_intercompany/models/stock_picking.py +++ b/stock_intercompany/models/stock_picking.py @@ -41,7 +41,8 @@ def _get_counterpart_picking_vals(self, company): "picking_type_id": ptype.id, "state": "draft", "location_id": self.env.ref("stock.stock_location_suppliers").id, - "location_dest_id": warehouse.lot_stock_id.id, + "location_dest_id": ptype.default_location_dest_id.id + or warehouse.lot_stock_id.id, "counterpart_of_picking_id": self.id, "move_ids": move_ids, "move_line_ids": move_line_ids, diff --git a/stock_intercompany_bidirectional/models/stock_picking.py b/stock_intercompany_bidirectional/models/stock_picking.py index 7c0cde851c7..07dba1ab6b7 100644 --- a/stock_intercompany_bidirectional/models/stock_picking.py +++ b/stock_intercompany_bidirectional/models/stock_picking.py @@ -39,13 +39,16 @@ def _check_company_consistency(self, company): move_ids, move_line_ids = super()._check_company_consistency(company) warehouse = company.intercompany_in_type_id.warehouse_id + location_dest = company.intercompany_in_type_id.default_location_dest_id stock_move_line_obj = self.env["stock.move.line"] # Remove package-related data and update destination location # in move_ids and move_line_ids for move_data in move_ids: # Update destination location for each move - move_data[2]["location_dest_id"] = warehouse.lot_stock_id.id + move_data[2]["location_dest_id"] = ( + location_dest.id or warehouse.lot_stock_id.id + ) # Set rule_id to False move_data[2]["rule_id"] = False for line_data in move_line_ids: @@ -54,7 +57,7 @@ def _check_company_consistency(self, company): { "package_level_id": False, "package_id": False, - "location_dest_id": warehouse.lot_stock_id.id, + "location_dest_id": location_dest.id or warehouse.lot_stock_id.id, } )