mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-09 15:29:30 +00:00
fix: validate shelf life for automatically created expiring batches (#58911)
Co-authored-by: Ajish18 <ajishiyappan1@gmail.com>
This commit is contained in:
@@ -219,6 +219,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()
|
||||
@@ -398,6 +399,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