From e5d3f2a1abb3918dc90776881897a0a925c0db00 Mon Sep 17 00:00:00 2001 From: svs-odoo Date: Mon, 28 Oct 2019 10:15:05 +0000 Subject: [PATCH] [IMP] product_expiry: hide removal date on quant When user goes on product's quants, hides the "Removal Date" field if the product doesn't use expiration dates. Also, set it as optional to be hide if the user wants. closes odoo/odoo#39425 Signed-off-by: Arnold Moyaux --- addons/product_expiry/models/product_product.py | 10 ++++++++++ addons/product_expiry/views/stock_quant_views.xml | 5 +++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/addons/product_expiry/models/product_product.py b/addons/product_expiry/models/product_product.py index 964fa7820ba..9f70ba56b7f 100644 --- a/addons/product_expiry/models/product_product.py +++ b/addons/product_expiry/models/product_product.py @@ -4,6 +4,16 @@ from odoo import fields, models +class Product(models.Model): + _inherit = "product.product" + + def action_open_quants(self): + # Override to hide the `removal_date` column if not needed. + if not any(product.use_expiration_date for product in self): + self = self.with_context(hide_removal_date=True) + return super().action_open_quants() + + class ProductTemplate(models.Model): _inherit = 'product.template' diff --git a/addons/product_expiry/views/stock_quant_views.xml b/addons/product_expiry/views/stock_quant_views.xml index f6d8204b508..7415b66f371 100644 --- a/addons/product_expiry/views/stock_quant_views.xml +++ b/addons/product_expiry/views/stock_quant_views.xml @@ -37,8 +37,9 @@ removal_date < current_date or inventory_quantity < 0 - - + +