fix: batch message ux improved

This commit is contained in:
vishdha 2020-04-13 12:27:26 +05:30
parent 0b34b90e71
commit cfaf638cc2

View File

@ -87,10 +87,11 @@ class StockLedgerEntry(Document):
# check if batch number is required
if self.voucher_type != 'Stock Reconciliation':
if item_det.has_batch_no ==1:
batch_item = self.item_code if self.item_code == item_det.item_name else self.item_code + ":" + item_det.item_name
if not self.batch_no:
frappe.throw(_("Batch number is mandatory for Item {0}:{1}").format(self.item_code, item_det.item_name))
frappe.throw(_("Batch number is mandatory for Item {0}").format(batch_item))
elif not frappe.db.get_value("Batch",{"item": self.item_code, "name": self.batch_no}):
frappe.throw(_("{0} is not a valid Batch Number for Item {1}:{2}").format(self.batch_no, self.item_code, item_det.item_name))
frappe.throw(_("{0} is not a valid Batch Number for Item {1}").format(self.batch_no, batch_item))
elif item_det.has_batch_no ==0 and self.batch_no and self.is_cancelled == "No":
frappe.throw(_("The Item {0} cannot have Batch").format(self.item_code))