fix: 'NoneType' object has no attribute 'has_serial_no'
This commit is contained in:
@@ -64,6 +64,18 @@ class StockController(AccountsController):
|
|||||||
self.validate_internal_transfer()
|
self.validate_internal_transfer()
|
||||||
self.validate_putaway_capacity()
|
self.validate_putaway_capacity()
|
||||||
|
|
||||||
|
def validate_items_exist(self):
|
||||||
|
if not self.get("items"):
|
||||||
|
return
|
||||||
|
|
||||||
|
items = [d.item_code for d in self.get("items")]
|
||||||
|
|
||||||
|
exists_items = frappe.get_all("Item", filters={"name": ("in", items)}, pluck="name")
|
||||||
|
non_exists_items = set(items) - set(exists_items)
|
||||||
|
|
||||||
|
if non_exists_items:
|
||||||
|
frappe.throw(_("Items {0} do not exist in the Item master.").format(", ".join(non_exists_items)))
|
||||||
|
|
||||||
def validate_duplicate_serial_and_batch_bundle(self, table_name):
|
def validate_duplicate_serial_and_batch_bundle(self, table_name):
|
||||||
if not self.get(table_name):
|
if not self.get(table_name):
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ class StockReconciliation(StockController):
|
|||||||
self.head_row = ["Item Code", "Warehouse", "Quantity", "Valuation Rate"]
|
self.head_row = ["Item Code", "Warehouse", "Quantity", "Valuation Rate"]
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
|
self.validate_items_exist()
|
||||||
if not self.expense_account:
|
if not self.expense_account:
|
||||||
self.expense_account = frappe.get_cached_value(
|
self.expense_account = frappe.get_cached_value(
|
||||||
"Company", self.company, "stock_adjustment_account"
|
"Company", self.company, "stock_adjustment_account"
|
||||||
@@ -162,6 +163,9 @@ class StockReconciliation(StockController):
|
|||||||
def set_current_serial_and_batch_bundle(self, voucher_detail_no=None, save=False) -> None:
|
def set_current_serial_and_batch_bundle(self, voucher_detail_no=None, save=False) -> None:
|
||||||
"""Set Serial and Batch Bundle for each item"""
|
"""Set Serial and Batch Bundle for each item"""
|
||||||
for item in self.items:
|
for item in self.items:
|
||||||
|
if not frappe.db.exists("Item", item.item_code):
|
||||||
|
frappe.throw(_("Item {0} does not exist").format(item.item_code))
|
||||||
|
|
||||||
if not item.reconcile_all_serial_batch and item.serial_and_batch_bundle:
|
if not item.reconcile_all_serial_batch and item.serial_and_batch_bundle:
|
||||||
bundle = self.get_bundle_for_specific_serial_batch(item)
|
bundle = self.get_bundle_for_specific_serial_batch(item)
|
||||||
item.current_serial_and_batch_bundle = bundle.name
|
item.current_serial_and_batch_bundle = bundle.name
|
||||||
@@ -357,6 +361,9 @@ class StockReconciliation(StockController):
|
|||||||
|
|
||||||
def set_new_serial_and_batch_bundle(self):
|
def set_new_serial_and_batch_bundle(self):
|
||||||
for item in self.items:
|
for item in self.items:
|
||||||
|
if not item.item_code:
|
||||||
|
continue
|
||||||
|
|
||||||
if item.use_serial_batch_fields:
|
if item.use_serial_batch_fields:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user