From 54fe71d62df5803eabcf267e1c2913cfa37aac79 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Wed, 13 May 2020 07:27:36 +0000 Subject: [PATCH] [FIX] sale_stock: Unable to set default warehouse when creating a quotation Steps to reproduce the bug: - Go to inventory > settings > enable multiple warehouses - Let's consider the default warehouse W - Create a new warehouses NW - Enable debug mode - Go to sales > create a new quotation - Go to the other information tab > change default warehouse W to the newly created warehouse NW - Click on the bug > go to set defaults > warehouse=NW > save default - Refresh the page > Go to sales > create a new quotation - Go to other information tab > observe the warehouse Bug: The warehouse was W instead of NW opw:2254084 closes odoo/odoo#51237 X-original-commit: 80c0821c0e902a68f15a839ff7d2f6beece43dc3 Signed-off-by: Simon Goffin (sig) --- addons/sale_stock/models/sale_order.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/sale_stock/models/sale_order.py b/addons/sale_stock/models/sale_order.py index 8ead12b9f79..41e4e6d5bb4 100644 --- a/addons/sale_stock/models/sale_order.py +++ b/addons/sale_stock/models/sale_order.py @@ -148,7 +148,8 @@ class SaleOrder(models.Model): @api.onchange('company_id') def _onchange_company_id(self): if self.company_id: - self.warehouse_id = self.user_id.with_company(self.company_id.id)._get_default_warehouse_id().id + warehouse_id = self.env['ir.default'].get_model_defaults('sale.order').get('warehouse_id') + self.warehouse_id = warehouse_id or self.user_id.with_company(self.company_id.id)._get_default_warehouse_id().id @api.onchange('user_id') def onchange_user_id(self):