[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>
This commit is contained in:
@@ -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'
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user