perf: skip warehouse validation for non-stock items
This commit is contained in:
parent
03e6a6c699
commit
199a6da960
@ -1264,25 +1264,13 @@ class AccountsController(TransactionBase):
|
|||||||
return get_company_default(self.company, fieldname, ignore_validation=ignore_validation)
|
return get_company_default(self.company, fieldname, ignore_validation=ignore_validation)
|
||||||
|
|
||||||
def get_stock_items(self):
|
def get_stock_items(self):
|
||||||
if hasattr(self, "_stock_items") and self._stock_items:
|
|
||||||
return self._stock_items
|
|
||||||
|
|
||||||
stock_items = []
|
stock_items = []
|
||||||
item_codes = list(set(item.item_code for item in self.get("items")))
|
item_codes = list(set(item.item_code for item in self.get("items")))
|
||||||
if item_codes:
|
if item_codes:
|
||||||
stock_items = [
|
stock_items = frappe.db.get_values(
|
||||||
r[0]
|
"Item", {"name": ["in", item_codes], "is_stock_item": 1}, pluck="name", cache=True
|
||||||
for r in frappe.db.sql(
|
|
||||||
"""
|
|
||||||
select name from `tabItem`
|
|
||||||
where name in (%s) and is_stock_item=1
|
|
||||||
"""
|
|
||||||
% (", ".join(["%s"] * len(item_codes)),),
|
|
||||||
item_codes,
|
|
||||||
)
|
)
|
||||||
]
|
|
||||||
|
|
||||||
self._stock_items = stock_items
|
|
||||||
return stock_items
|
return stock_items
|
||||||
|
|
||||||
def set_total_advance_paid(self):
|
def set_total_advance_paid(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user