From 9a7e66bc0e7a089537e5784f2e993ab06c4325ca Mon Sep 17 00:00:00 2001 From: svs-odoo Date: Tue, 4 Jun 2019 12:39:43 +0000 Subject: [PATCH] [IMP] stock: hide quant lot_id when no tracked On the editable list quant view, when user come from a non tracked product, the `lot_id` field is hidden. Task #2006337 --- addons/stock/models/product.py | 4 +++- addons/stock/views/stock_quant_views.xml | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/stock/models/product.py b/addons/stock/models/product.py index 42baccfe24d..e1a7bc0f02a 100644 --- a/addons/stock/models/product.py +++ b/addons/stock/models/product.py @@ -414,7 +414,9 @@ class Product(models.Model): def action_open_quants(self): location_domain = self._get_domain_locations()[0] domain = expression.AND([[('product_id', 'in', self.ids)], location_domain]) - self = self.with_context(hide_location=not self.user_has_groups('stock.group_stock_multi_locations')) + hide_location = not self.user_has_groups('stock.group_stock_multi_locations') + hide_lot = all([product.tracking == 'none' for product in self]) + self = self.with_context(hide_location=hide_location, hide_lot=hide_lot) # If user have rights to write on quant, we define the view as editable. if self.user_has_groups('stock.group_stock_manager'): diff --git a/addons/stock/views/stock_quant_views.xml b/addons/stock/views/stock_quant_views.xml index 09c425167c2..0ca14e66877 100644 --- a/addons/stock/views/stock_quant_views.xml +++ b/addons/stock/views/stock_quant_views.xml @@ -89,6 +89,7 @@ 'readonly': ['|', ('id', '!=', False), ('tracking', 'not in', ['serial', 'lot'])], 'required': [('tracking', '!=', 'none')] }" + invisible="context.get('hide_lot', False)" context="{'default_product_id': product_id}" domain="[('product_id', '=', product_id)]"/>