From 062ad4d99809593c80aaf7246e5c1ea3830cf7bf Mon Sep 17 00:00:00 2001 From: Arnold Moyaux Date: Tue, 28 Dec 2021 10:52:10 +0000 Subject: [PATCH] [FIX] stock: add a partner on warehouse doesn't set correct properties - Install stock with demo data - Log in Chicago company - Chicago partner has inter-company transit set on Customer and Supplier locations - Jeff Lawson (partner address of chicago warehouse) has Customer and supplier locations set instead of inter-company transit. It prevents the following usecase: - Enable synch SO and PO between chicago and SF company with automatic confirmation - Create a product with route Buy and MTO - Create a PO in company chicago that buy to SF comapny - Validate the PO You have an error with rule since it try to pull from intercompany transit instead of customer However if you log in San Francisco company Jeff Lawson has inter-company transit set while it should not. It happens because during the demo install the partner is added through a write and the company is not provided and the code was missing a part in that case. closes odoo/odoo#82006 X-original-commit: 46c49ce4f6c9677463425981f01b69117c11943e Signed-off-by: Arnold Moyaux --- addons/stock/models/stock_warehouse.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/stock/models/stock_warehouse.py b/addons/stock/models/stock_warehouse.py index f57ee7eb4b5..ce65bd13dd4 100644 --- a/addons/stock/models/stock_warehouse.py +++ b/addons/stock/models/stock_warehouse.py @@ -173,7 +173,11 @@ class Warehouse(models.Model): # If another partner assigned if vals.get('partner_id'): - warehouses._update_partner_data(vals['partner_id'], vals.get('company_id')) + if vals.get('company_id'): + warehouses._update_partner_data(vals['partner_id'], vals.get('company_id')) + else: + for warehouse in self: + warehouse._update_partner_data(vals['partner_id'], warehouse.company_id.id) res = super(Warehouse, self).write(vals)