Merge pull request #2628 from neilLasrado/batch-validation

Batch Validation
This commit is contained in:
Nabin Hait 2015-02-03 18:33:49 +05:30
commit 279bb6f3ed
2 changed files with 12 additions and 11 deletions

View File

@ -64,7 +64,6 @@ class StockEntry(StockController):
self.validate_valuation_rate()
self.set_total_amount()
def on_submit(self):
self.update_stock_ledger()
@ -330,7 +329,8 @@ class StockEntry(StockController):
"""validation: finished good quantity should be same as manufacturing quantity"""
for d in self.get('items'):
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):
"""validate item with reference doc"""

View File

@ -62,15 +62,16 @@ class StockLedgerEntry(Document):
frappe.throw(_("Item {0} must be a stock Item").format(self.item_code))
# check if batch number is required
if item_det.has_batch_no =='Yes' and self.voucher_type != 'Stock Reconciliation':
if not self.batch_no:
frappe.throw("Batch number is mandatory for Item {0}".format(self.item_code))
# check if batch belongs to item
if 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))
if self.voucher_type != 'Stock Reconciliation':
if item_det.has_batch_no =='Yes':
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))
elif item_det.has_batch_no =='No' and self.batch_no:
frappe.throw(_("The Item {0} cannot have Batch").format(self.item_code))
if item_det.has_variants:
frappe.throw(_("Stock cannot exist for Item {0} since has variants").format(self.item_code),
ItemTemplateCannotHaveStock)