diff --git a/addons/product_expiry/models/product_product.py b/addons/product_expiry/models/product_product.py index a055f650286..3dfcb1a35bd 100644 --- a/addons/product_expiry/models/product_product.py +++ b/addons/product_expiry/models/product_product.py @@ -7,7 +7,10 @@ from odoo import fields, models class ProductTemplate(models.Model): _inherit = 'product.template' - life_time = fields.Integer(string='Product Life Time', + use_expiration_date = fields.Boolean(string='Expiration Date', + help='When this box is ticked, you have the possibility to specify dates to manage' + ' product expiration, on the product and on the corresponding lot/serial numbers') + expiration_time = fields.Integer(string='Product Life Time', help='Number of days before the goods may become dangerous and must not be consumed. It will be computed on the lot/serial number.') use_time = fields.Integer(string='Product Use Time', help='Number of days before the goods starts deteriorating, without being dangerous yet. It will be computed using the lot/serial number.') diff --git a/addons/product_expiry/models/production_lot.py b/addons/product_expiry/models/production_lot.py index 566483eb1a1..384207fb9c4 100644 --- a/addons/product_expiry/models/production_lot.py +++ b/addons/product_expiry/models/production_lot.py @@ -7,7 +7,9 @@ from odoo import api, fields, models, SUPERUSER_ID, _ class StockProductionLot(models.Model): _inherit = 'stock.production.lot' - life_date = fields.Datetime(string='End of Life Date', + use_expiration_date = fields.Boolean( + string='Use Expiration Date', related='product_id.use_expiration_date') + expiration_date = fields.Datetime(string='End of Life Date', help='This is the date on which the goods with this Serial Number may become dangerous and must not be consumed.') use_date = fields.Datetime(string='Best before Date', help='This is the date on which the goods with this Serial Number start deteriorating, without being dangerous yet.') @@ -29,7 +31,7 @@ class StockProductionLot(models.Model): def _get_dates(self, product_id=None): """Returns dates based on number of days configured in current lot's product.""" mapped_fields = { - 'life_date': 'life_time', + 'expiration_date': 'expiration_time', 'use_date': 'use_time', 'removal_date': 'removal_time', 'alert_date': 'alert_time' diff --git a/addons/product_expiry/views/product_template_views.xml b/addons/product_expiry/views/product_template_views.xml index 70579f69a77..ae1c0bcd653 100644 --- a/addons/product_expiry/views/product_template_views.xml +++ b/addons/product_expiry/views/product_template_views.xml @@ -5,16 +5,20 @@ product.template - - + + + + +