mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-09 15:29:30 +00:00
Merge pull request #58914 from frappe/mergify/bp/version-15-hotfix/pr-58911
fix: validate shelf life for automatically created expiring batches (backport #58911)
This commit is contained in:
@@ -194,6 +194,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()
|
||||
@@ -344,6 +345,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
|
||||
|
||||
Reference in New Issue
Block a user