fix: Make shelf life mandatory in Batched Item if it has expiry date (#21044)

This commit is contained in:
Marica 2020-03-26 13:29:02 +05:30 committed by GitHub
parent 89cac5af16
commit 38cba153b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -122,8 +122,11 @@ class Batch(Document):
self.expiry_date = add_days(self.manufacturing_date, shelf_life_in_days)
if has_expiry_date and not self.expiry_date:
frappe.msgprint(_('Expiry date is mandatory for selected item.'))
frappe.throw(_("Set item's shelf life in days, to set expiry based on manufacturing date plus shelf-life."))
frappe.throw(msg=_("Please set {0} for Batched Item {1}, which is used to set {2} on Submit.") \
.format(frappe.bold("Shelf Life in Days"),
frappe.utils.get_link_to_form("Item", self.item),
frappe.bold("Batch Expiry Date")),
title=_("Expiry Date Mandatory"))
def get_name_from_naming_series(self):
"""

View File

@ -343,7 +343,8 @@
{
"fieldname": "shelf_life_in_days",
"fieldtype": "Int",
"label": "Shelf Life In Days"
"label": "Shelf Life In Days",
"mandatory_depends_on": "eval:doc.has_batch_no && doc.has_expiry_date"
},
{
"default": "2099-12-31",
@ -1045,7 +1046,7 @@
"image_field": "image",
"links": [],
"max_attachments": 1,
"modified": "2020-01-02 19:13:59.295963",
"modified": "2020-03-24 16:14:36.950677",
"modified_by": "Administrator",
"module": "Stock",
"name": "Item",