perf: skip warehouse validation for non-stock items
(cherry picked from commit 6528218ac3)
# Conflicts:
# erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
This commit is contained in:
committed by
mergify-bot
parent
00cb0d0294
commit
ad91d57a41
@@ -245,9 +245,15 @@ class PurchaseInvoice(BuyingController):
|
||||
|
||||
def validate_warehouse(self, for_validate=True):
|
||||
if self.update_stock and for_validate:
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
for d in self.get("items"):
|
||||
if not d.warehouse:
|
||||
=======
|
||||
stock_items = self.get_stock_items()
|
||||
for d in self.get("items"):
|
||||
if not d.warehouse and d.item_code in stock_items:
|
||||
>>>>>>> 6528218ac3 (perf: skip warehouse validation for non-stock items)
|
||||
frappe.throw(
|
||||
_(
|
||||
"Warehouse required at Row No {0}, please set default warehouse for the item {1} for the company {2}"
|
||||
|
||||
@@ -1265,6 +1265,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:
|
||||
@@ -1280,6 +1283,7 @@ class AccountsController(TransactionBase):
|
||||
)
|
||||
]
|
||||
|
||||
self._stock_items = stock_items
|
||||
return stock_items
|
||||
|
||||
def set_total_advance_paid(self):
|
||||
|
||||
Reference in New Issue
Block a user