diff options
| author | svs-odoo <svs@odoo.com> | 2019-10-28 10:15:05 +0000 |
|---|---|---|
| committer | svs-odoo <svs@odoo.com> | 2019-10-28 12:31:58 +0000 |
| commit | e5d3f2a1abb3918dc90776881897a0a925c0db00 (patch) | |
| tree | 749ab6a7c4430e887290aa2c7a3a7d09c85f315f | |
| parent | 5ac04570f12924c6da274031734c36b182e207ee (diff) | |
[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 <amoyaux@users.noreply.github.com>
| -rw-r--r-- | addons/product_expiry/models/product_product.py | 10 | ||||
| -rw-r--r-- | 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 </attribute> </xpath> - <xpath expr="//field[@name='inventory_quantity']" position="before" > - <field name="removal_date"/> + <xpath expr="//field[@name='inventory_quantity']" position="before"> + <field name="removal_date" optional="show" + invisible="context.get('hide_removal_date')"/> </xpath> </field> </record> |
