perf: skip warehouse validation for non-stock items
This commit is contained in:
parent
0cb9cdb414
commit
6528218ac3
@ -249,8 +249,9 @@ class PurchaseInvoice(BuyingController):
|
||||
|
||||
def validate_warehouse(self, for_validate=True):
|
||||
if self.update_stock and for_validate:
|
||||
stock_items = self.get_stock_items()
|
||||
for d in self.get("items"):
|
||||
if not d.warehouse and not d.is_fixed_asset:
|
||||
if not d.warehouse and d.item_code in stock_items:
|
||||
frappe.throw(
|
||||
_(
|
||||
"Row No {0}: Warehouse is required. Please set a Default Warehouse for Item {1} and Company {2}"
|
||||
|
@ -1264,6 +1264,9 @@ class AccountsController(TransactionBase):
|
||||
return get_company_default(self.company, fieldname, ignore_validation=ignore_validation)
|
||||
|
||||
def get_stock_items(self):
|
||||
if hasattr(self, "_stock_items") and self._stock_items:
|
||||
return self._stock_items
|
||||
|
||||
stock_items = []
|
||||
item_codes = list(set(item.item_code for item in self.get("items")))
|
||||
if item_codes:
|
||||
@ -1279,6 +1282,7 @@ class AccountsController(TransactionBase):
|
||||
)
|
||||
]
|
||||
|
||||
self._stock_items = stock_items
|
||||
return stock_items
|
||||
|
||||
def set_total_advance_paid(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user