[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) <sig@openerp.com>
This commit is contained in:
Goffin Simon
2020-05-14 09:34:10 +00:00
parent 39e93532c7
commit 54fe71d62d
+2 -1
View File
@@ -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):