diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 3ad61d4dc2..3a20d3f232 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -1264,25 +1264,13 @@ 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: - stock_items = [ - r[0] - 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, - ) - ] + stock_items = frappe.db.get_values( + "Item", {"name": ["in", item_codes], "is_stock_item": 1}, pluck="name", cache=True + ) - self._stock_items = stock_items return stock_items def set_total_advance_paid(self):