From da3eddbd51d40317a74e859cd546e2d1ff0c9459 Mon Sep 17 00:00:00 2001 From: Arnold Moyaux Date: Mon, 9 Mar 2020 13:20:51 +0000 Subject: [PATCH] [FIX] stock: warehouse code should impact picking type Usecase to reproduce: - Create Warehouse with code A -> Picking type sequence start with A/ - Set the warehouse's code to B -> Picking type sequence remains A/ - Set the warehouse's code to C -> Picking type sequence become B/ It happens because _update_name_and_code is called before the write and it updates the picking_type's sequence with warehouse current name and code. --- addons/stock/models/stock_warehouse.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/addons/stock/models/stock_warehouse.py b/addons/stock/models/stock_warehouse.py index 930cbe05ff3..44f6942c943 100644 --- a/addons/stock/models/stock_warehouse.py +++ b/addons/stock/models/stock_warehouse.py @@ -132,10 +132,6 @@ class Warehouse(models.Model): Route = self.env['stock.location.route'] warehouses = self.with_context(active_test=False) - - if vals.get('code') or vals.get('name'): - warehouses._update_name_and_code(vals.get('name'), vals.get('code')) - warehouses._create_missing_locations(vals) if vals.get('reception_steps'): @@ -157,6 +153,9 @@ class Warehouse(models.Model): res = super(Warehouse, self).write(vals) + if vals.get('code') or vals.get('name'): + warehouses._update_name_and_code(vals.get('name'), vals.get('code')) + for warehouse in warehouses: # check if we need to delete and recreate route depends = [depend for depends in [value.get('depends', []) for value in warehouse._get_routes_values().values()] for depend in depends]