mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-25 16:04:46 +00:00
Merge pull request #2628 from neilLasrado/batch-validation
Batch Validation
This commit is contained in:
@@ -64,7 +64,6 @@ class StockEntry(StockController):
|
|||||||
self.validate_valuation_rate()
|
self.validate_valuation_rate()
|
||||||
self.set_total_amount()
|
self.set_total_amount()
|
||||||
|
|
||||||
|
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
self.update_stock_ledger()
|
self.update_stock_ledger()
|
||||||
|
|
||||||
@@ -330,7 +329,8 @@ class StockEntry(StockController):
|
|||||||
"""validation: finished good quantity should be same as manufacturing quantity"""
|
"""validation: finished good quantity should be same as manufacturing quantity"""
|
||||||
for d in self.get('items'):
|
for d in self.get('items'):
|
||||||
if d.bom_no and flt(d.transfer_qty) != flt(self.fg_completed_qty):
|
if d.bom_no and flt(d.transfer_qty) != flt(self.fg_completed_qty):
|
||||||
frappe.throw(_("Quantity in row {0} ({1}) must be same as manufactured quantity {2}").format(d.idx, d.transfer_qty, self.fg_completed_qty))
|
frappe.throw(_("Quantity in row {0} ({1}) must be same as manufactured quantity {2}"). \
|
||||||
|
format(d.idx, d.transfer_qty, self.fg_completed_qty))
|
||||||
|
|
||||||
def validate_return_reference_doc(self):
|
def validate_return_reference_doc(self):
|
||||||
"""validate item with reference doc"""
|
"""validate item with reference doc"""
|
||||||
|
|||||||
@@ -62,14 +62,15 @@ class StockLedgerEntry(Document):
|
|||||||
frappe.throw(_("Item {0} must be a stock Item").format(self.item_code))
|
frappe.throw(_("Item {0} must be a stock Item").format(self.item_code))
|
||||||
|
|
||||||
# check if batch number is required
|
# check if batch number is required
|
||||||
if item_det.has_batch_no =='Yes' and self.voucher_type != 'Stock Reconciliation':
|
if self.voucher_type != 'Stock Reconciliation':
|
||||||
if not self.batch_no:
|
if item_det.has_batch_no =='Yes':
|
||||||
frappe.throw("Batch number is mandatory for Item {0}".format(self.item_code))
|
if not self.batch_no:
|
||||||
|
frappe.throw(_("Batch number is mandatory for Item {0}").format(self.item_code))
|
||||||
|
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}").format(self.batch_no, self.item_code))
|
||||||
|
|
||||||
# check if batch belongs to item
|
elif item_det.has_batch_no =='No' and self.batch_no:
|
||||||
if not frappe.db.get_value("Batch",
|
frappe.throw(_("The Item {0} cannot have Batch").format(self.item_code))
|
||||||
{"item": self.item_code, "name": self.batch_no}):
|
|
||||||
frappe.throw(_("{0} is not a valid Batch Number for Item {1}").format(self.batch_no, self.item_code))
|
|
||||||
|
|
||||||
if item_det.has_variants:
|
if item_det.has_variants:
|
||||||
frappe.throw(_("Stock cannot exist for Item {0} since has variants").format(self.item_code),
|
frappe.throw(_("Stock cannot exist for Item {0} since has variants").format(self.item_code),
|
||||||
|
|||||||
Reference in New Issue
Block a user