From a7051cb9b59d3f86670a2cb5968af9585a083ab9 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Fri, 14 Apr 2023 09:59:42 +0530 Subject: [PATCH] fix: Don't use stale item details (#34847) --- erpnext/controllers/accounts_controller.py | 13 +------------ erpnext/stock/get_item_details.py | 22 +++------------------- 2 files changed, 4 insertions(+), 31 deletions(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index a347323e35..7fcc28bac3 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -515,7 +515,6 @@ class AccountsController(TransactionBase): parent_dict.update({"customer": parent_dict.get("party_name")}) self.pricing_rules = [] - basic_item_details_map = {} for item in self.get("items"): if item.get("item_code"): @@ -535,17 +534,7 @@ class AccountsController(TransactionBase): if self.get("is_subcontracted"): args["is_subcontracted"] = self.is_subcontracted - basic_details = basic_item_details_map.get(item.item_code) - ret, basic_item_details = get_item_details( - args, - self, - for_validate=True, - overwrite_warehouse=False, - return_basic_details=True, - basic_details=basic_details, - ) - - basic_item_details_map.setdefault(item.item_code, basic_item_details) + ret = get_item_details(args, self, for_validate=True, overwrite_warehouse=False) for fieldname, value in ret.items(): if item.meta.get_field(fieldname) and value is not None: diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index 2cf3797a36..ce85702f48 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -35,14 +35,7 @@ purchase_doctypes = [ @frappe.whitelist() -def get_item_details( - args, - doc=None, - for_validate=False, - overwrite_warehouse=True, - return_basic_details=False, - basic_details=None, -): +def get_item_details(args, doc=None, for_validate=False, overwrite_warehouse=True): """ args = { "item_code": "", @@ -80,12 +73,7 @@ def get_item_details( if doc.get("doctype") == "Purchase Invoice": args["bill_date"] = doc.get("bill_date") - if not basic_details: - out = get_basic_details(args, item, overwrite_warehouse) - else: - out = basic_details - - basic_details = out.copy() + out = get_basic_details(args, item, overwrite_warehouse) get_item_tax_template(args, item, out) out["item_tax_rate"] = get_item_tax_map( @@ -154,11 +142,7 @@ def get_item_details( out.amount = flt(args.qty) * flt(out.rate) out = remove_standard_fields(out) - - if return_basic_details: - return out, basic_details - else: - return out + return out def remove_standard_fields(details):