fixes for batch validations

This commit is contained in:
Neil Trini Lasrado 2015-02-03 18:23:46 +05:30
parent 9448aaf2a6
commit 14e24a947b
2 changed files with 10 additions and 14 deletions

View File

@ -63,7 +63,6 @@ class StockEntry(StockController):
self.validate_fiscal_year()
self.validate_valuation_rate()
self.set_total_amount()
self.validate_batch_item()
def on_submit(self):
self.update_stock_ledger()
@ -661,10 +660,6 @@ class StockEntry(StockController):
frappe.throw(_("Item or Warehouse for row {0} does not match Material Request").format(item.idx),
frappe.MappingMismatchError)
def validate_batch_item(self):
if frappe.db.get_value("Item",self.item,"has_batch_no") =='No':
frappe.throw(_("The selected item cannot have Batch"))
@frappe.whitelist()
def get_party_details(ref_dt, ref_dn):
if ref_dt in ["Delivery Note", "Sales Invoice"]:

View File

@ -62,14 +62,15 @@ 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))
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))
# 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))
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),