fix: Don't use stale item details (#34847)

This commit is contained in:
Deepesh Garg 2023-04-14 09:59:42 +05:30 committed by GitHub
parent 66130493eb
commit a7051cb9b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 31 deletions

View File

@ -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:

View File

@ -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):