From 5bd4514c6fec80cfc3d7e5353d4e54c8a7b2ed31 Mon Sep 17 00:00:00 2001 From: Ravi Patel Date: Mon, 18 Jul 2016 18:14:49 +0530 Subject: [PATCH] [IMP] prodcut_expiry: 'Product Alert Time' improvement - Hide life_time, use_time, removal_time and alert_time if tracking = no tracking - Change the tooltip of these fields(life_time, use_time, removal_time, alert_time) - Add filter 'Expiration Alert' on the Lot/Serial Number list view based on the lot/sn alert date - Add a tag 'Expiration alert' when the alert_date is reached. --- .../product_expiry/models/product_product.py | 8 +++--- .../product_expiry/models/production_lot.py | 7 +++++ .../views/product_template_views.xml | 26 +++++++++++++++---- .../views/production_lot_views.xml | 16 ++++++++++++ 4 files changed, 48 insertions(+), 9 deletions(-) diff --git a/addons/product_expiry/models/product_product.py b/addons/product_expiry/models/product_product.py index 709a3127619..86094cfed16 100644 --- a/addons/product_expiry/models/product_product.py +++ b/addons/product_expiry/models/product_product.py @@ -8,10 +8,10 @@ class ProductTemplate(models.Model): _inherit = 'product.template' life_time = fields.Integer(string='Product Life Time', - help='When a new a Serial Number is issued, this is the number of days before the goods may become dangerous and must not be consumed.') + 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='When a new a Serial Number is issued, this is the number of days before the goods starts deteriorating, without being dangerous yet.') + help='Number of days before the goods starts deteriorating, without being dangerous yet. It will be computed on the lot/serial number.') removal_time = fields.Integer(string='Product Removal Time', - help='When a new a Serial Number is issued, this is the number of days before the goods should be removed from the stock.') + help='Number of days before the goods should be removed from the stock. It will be computed on the lot/serial number.') alert_time = fields.Integer(string='Product Alert Time', - help='When a new a Serial Number is issued, this is the number of days before an alert should be notified.') + help='Number of days before an alert should be raised on the lot/serial number.') diff --git a/addons/product_expiry/models/production_lot.py b/addons/product_expiry/models/production_lot.py index d6d1b0fa7b9..95e37a31deb 100644 --- a/addons/product_expiry/models/production_lot.py +++ b/addons/product_expiry/models/production_lot.py @@ -15,6 +15,13 @@ class StockProductionLot(models.Model): help='This is the date on which the goods with this Serial Number should be removed from the stock.') alert_date = fields.Datetime(string='Alert Date', help="This is the date on which an alert should be notified about the goods with this Serial Number.") + product_expiry_alert = fields.Boolean(compute='_compute_product_expiry_alert', help="The Alert Date has been reached.") + + @api.depends('alert_date') + def _compute_product_expiry_alert(self): + current_date = fields.Datetime.now() + for lot in self.filtered(lambda l: l.alert_date): + lot.product_expiry_alert = lot.alert_date <= current_date def _get_dates(self, product_id=None): """Returns dates based on number of days configured in current lot's product.""" diff --git a/addons/product_expiry/views/product_template_views.xml b/addons/product_expiry/views/product_template_views.xml index 9f654eb192c..a8587dbb530 100644 --- a/addons/product_expiry/views/product_template_views.xml +++ b/addons/product_expiry/views/product_template_views.xml @@ -6,11 +6,27 @@ - - - - - + + diff --git a/addons/product_expiry/views/production_lot_views.xml b/addons/product_expiry/views/production_lot_views.xml index 92b2040de6a..1209d32706a 100644 --- a/addons/product_expiry/views/production_lot_views.xml +++ b/addons/product_expiry/views/production_lot_views.xml @@ -16,7 +16,23 @@ + + + + Expiration Alert + + + stock.production.lot.search.inherit + stock.production.lot + + + + + + + +