diff --git a/product_expiry_ux/__manifest__.py b/product_expiry_ux/__manifest__.py index 012201842..67d14725c 100644 --- a/product_expiry_ux/__manifest__.py +++ b/product_expiry_ux/__manifest__.py @@ -1,6 +1,6 @@ { "name": "Products Expiration Date UX", - "version": "18.0.1.0.0", + "version": "19.0.1.0.0", "category": "Inventory/Inventory", "author": "ADHOC SA", "website": "www.adhoc.com.ar", @@ -14,7 +14,7 @@ ], "demo": [], "license": "AGPL-3", - "installable": False, + "installable": True, "auto_install": True, "application": False, } diff --git a/product_expiry_ux/models/stock_move_line.py b/product_expiry_ux/models/stock_move_line.py index 467fb5c07..eaa867870 100644 --- a/product_expiry_ux/models/stock_move_line.py +++ b/product_expiry_ux/models/stock_move_line.py @@ -24,11 +24,13 @@ def onchange_expiration_date(self): "expiration_date": self.expiration_date, } ) - lot.write( - { - "removal_date": lot.expiration_date - datetime.timedelta(days=prod.removal_time), - "use_date": lot.expiration_date - datetime.timedelta(days=prod.use_time), - } - ) - if not lot.alert_date: + dates_to_update = {} + if prod.removal_time: + dates_to_update["removal_date"] = lot.expiration_date - datetime.timedelta(days=prod.removal_time) + if prod.use_time: + dates_to_update["use_date"] = lot.expiration_date - datetime.timedelta(days=prod.use_time) + + if dates_to_update: + lot.write(dates_to_update) + if not lot.alert_date and prod.alert_time: lot.write({"alert_date": lot.expiration_date - datetime.timedelta(days=prod.alert_time)})