From 8a7b6a4f9c2ab2e8d208e735f86b0c9477a2ca64 Mon Sep 17 00:00:00 2001 From: Antoine Prieels Date: Mon, 11 Feb 2019 11:20:43 +0000 Subject: [PATCH] [IMP] repair: Hide lot_id and do not systematically reset lot_id - Hide lot_id field when product is not tracked - There was an onchange on the product_id that systematically set the lot_id to `False`. When giving default values for the lot_id and product_id through the context, the default value of the lot_id would be overwriten by the onchange. To fix this, we only reset the lot_id when it is inconsistent with the product_id. TaskId: 1909413 --- addons/repair/models/repair.py | 3 ++- addons/repair/views/repair_views.xml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/repair/models/repair.py b/addons/repair/models/repair.py index 30b99803eaf..6602a8462bd 100644 --- a/addons/repair/models/repair.py +++ b/addons/repair/models/repair.py @@ -159,7 +159,8 @@ class Repair(models.Model): @api.onchange('product_id') def onchange_product_id(self): self.guarantee_limit = False - self.lot_id = False + if (self.product_id and self.lot_id and self.lot_id.product_id != self.product_id) or not self.product_id: + self.lot_id = False if self.product_id: self.product_uom = self.product_id.uom_id.id diff --git a/addons/repair/views/repair_views.xml b/addons/repair/views/repair_views.xml index 30b6f7a369c..f96f4e472c2 100644 --- a/addons/repair/views/repair_views.xml +++ b/addons/repair/views/repair_views.xml @@ -58,7 +58,7 @@ - +