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)]"/>