From 7d7b902eac7960ff5f5c5b82b98a5991f788cbfe Mon Sep 17 00:00:00 2001 From: svs-odoo Date: Wed, 25 Sep 2019 14:08:45 +0000 Subject: [PATCH] [IMP] product_expiry: change expiry alert compute The production lot expiry alert was based on the field `alert_date`. Now, it will be based on the field `life_date` since if user set only one field, there is more chance this field will be filled but the field `alert_date` will not. Task #1938656 --- addons/product_expiry/models/production_lot.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/addons/product_expiry/models/production_lot.py b/addons/product_expiry/models/production_lot.py index 9d05232fcb4..062d696d95f 100644 --- a/addons/product_expiry/models/production_lot.py +++ b/addons/product_expiry/models/production_lot.py @@ -17,16 +17,17 @@ class StockProductionLot(models.Model): help='This is the date on which the goods with this Serial Number should be removed from the stock. This date will be used in FEFO removal strategy.') alert_date = fields.Datetime(string='Alert Date', help='Date to determine the expired lots and serial numbers using the filter "Expiration Alerts".') - product_expiry_alert = fields.Boolean(compute='_compute_product_expiry_alert', help="The Alert Date has been reached.") + product_expiry_alert = fields.Boolean(compute='_compute_product_expiry_alert', help="The Expiration Date has been reached.") product_expiry_reminded = fields.Boolean(string="Expiry has been reminded") - @api.depends('alert_date') + @api.depends('expiration_date') def _compute_product_expiry_alert(self): current_date = fields.Datetime.now() - lots = self.filtered(lambda l: l.alert_date) - for lot in lots: - lot.product_expiry_alert = lot.alert_date <= current_date - (self - lots).product_expiry_alert = False + for lot in self: + if lot.expiration_date: + lot.product_expiry_alert = lot.expiration_date <= current_date + else: + lot.product_expiry_alert = False def _get_dates(self, product_id=None): """Returns dates based on number of days configured in current lot's product."""