Merge pull request #58915 from frappe/mergify/bp/version-16-hotfix/pr-58911

fix: validate shelf life for automatically created expiring batches (backport #58911)
This commit is contained in:
Sudharsanan Ashok
2026-09-09 13:25:07 +05:30
committed by GitHub

View File

@@ -202,6 +202,7 @@ class Item(Document):
self.validate_conversion_factor()
self.validate_item_type()
self.validate_naming_series()
self.validate_shelf_life()
self.check_for_active_boms()
self.fill_customer_code()
self.check_item_tax()
@@ -377,6 +378,19 @@ class Item(Document):
).format(self.item_code)
)
def validate_shelf_life(self):
if (
self.has_batch_no
and self.has_expiry_date
and self.create_new_batch
and cint(self.shelf_life_in_days) <= 0
):
frappe.throw(
_("{0} must be greater than zero.").format(
self.get_label_from_fieldname("shelf_life_in_days")
)
)
def clear_retain_sample(self):
if not self.has_batch_no:
self.retain_sample = False