From 280e2f6e0404813a2541dc8934e10566c0003082 Mon Sep 17 00:00:00 2001 From: prro-odoo Date: Mon, 9 Aug 2021 08:54:06 +0000 Subject: [PATCH] [FIX] repair: display correct default location MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit How to reproduce the problem: - Install the repair App - Repairs -> Create (a Repair Order) (and activate the debug mode) - Change the Location Field to something else (than the usual default WH/Stock) - Open Developer Tools -> Set Defaults - For Defaults, choose "Location = [the changed Location]", "All Users" -> Save Default - Create a new Repair Order: the Location is not set to the default we set earlier through the Developer Tools Cause of the problem : an Onchange method was overriding the default Location Solution : it will now check, in the onchange, if the change is necessary, before overriding the default. opw-2545876 closes odoo/odoo#74871 X-original-commit: 9877ad1599513338c5333d3a728edb8d6ebcac26 Signed-off-by: Rémy Voet --- addons/repair/models/repair.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/repair/models/repair.py b/addons/repair/models/repair.py index 432e1f02b0a..25443b46ce8 100644 --- a/addons/repair/models/repair.py +++ b/addons/repair/models/repair.py @@ -193,8 +193,9 @@ class Repair(models.Model): @api.onchange('company_id') def _onchange_company_id(self): if self.company_id: - warehouse = self.env['stock.warehouse'].search([('company_id', '=', self.company_id.id)], limit=1) - self.location_id = warehouse.lot_stock_id + if self.location_id.company_id != self.company_id: + warehouse = self.env['stock.warehouse'].search([('company_id', '=', self.company_id.id)], limit=1) + self.location_id = warehouse.lot_stock_id else: self.location_id = False