fix: Don't use stale item details (#34847)
This commit is contained in:
parent
66130493eb
commit
a7051cb9b5
@ -515,7 +515,6 @@ class AccountsController(TransactionBase):
|
|||||||
parent_dict.update({"customer": parent_dict.get("party_name")})
|
parent_dict.update({"customer": parent_dict.get("party_name")})
|
||||||
|
|
||||||
self.pricing_rules = []
|
self.pricing_rules = []
|
||||||
basic_item_details_map = {}
|
|
||||||
|
|
||||||
for item in self.get("items"):
|
for item in self.get("items"):
|
||||||
if item.get("item_code"):
|
if item.get("item_code"):
|
||||||
@ -535,17 +534,7 @@ class AccountsController(TransactionBase):
|
|||||||
if self.get("is_subcontracted"):
|
if self.get("is_subcontracted"):
|
||||||
args["is_subcontracted"] = self.is_subcontracted
|
args["is_subcontracted"] = self.is_subcontracted
|
||||||
|
|
||||||
basic_details = basic_item_details_map.get(item.item_code)
|
ret = get_item_details(args, self, for_validate=True, overwrite_warehouse=False)
|
||||||
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)
|
|
||||||
|
|
||||||
for fieldname, value in ret.items():
|
for fieldname, value in ret.items():
|
||||||
if item.meta.get_field(fieldname) and value is not None:
|
if item.meta.get_field(fieldname) and value is not None:
|
||||||
|
@ -35,14 +35,7 @@ purchase_doctypes = [
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_item_details(
|
def get_item_details(args, doc=None, for_validate=False, overwrite_warehouse=True):
|
||||||
args,
|
|
||||||
doc=None,
|
|
||||||
for_validate=False,
|
|
||||||
overwrite_warehouse=True,
|
|
||||||
return_basic_details=False,
|
|
||||||
basic_details=None,
|
|
||||||
):
|
|
||||||
"""
|
"""
|
||||||
args = {
|
args = {
|
||||||
"item_code": "",
|
"item_code": "",
|
||||||
@ -80,12 +73,7 @@ def get_item_details(
|
|||||||
if doc.get("doctype") == "Purchase Invoice":
|
if doc.get("doctype") == "Purchase Invoice":
|
||||||
args["bill_date"] = doc.get("bill_date")
|
args["bill_date"] = doc.get("bill_date")
|
||||||
|
|
||||||
if not basic_details:
|
out = get_basic_details(args, item, overwrite_warehouse)
|
||||||
out = get_basic_details(args, item, overwrite_warehouse)
|
|
||||||
else:
|
|
||||||
out = basic_details
|
|
||||||
|
|
||||||
basic_details = out.copy()
|
|
||||||
|
|
||||||
get_item_tax_template(args, item, out)
|
get_item_tax_template(args, item, out)
|
||||||
out["item_tax_rate"] = get_item_tax_map(
|
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.amount = flt(args.qty) * flt(out.rate)
|
||||||
|
|
||||||
out = remove_standard_fields(out)
|
out = remove_standard_fields(out)
|
||||||
|
return out
|
||||||
if return_basic_details:
|
|
||||||
return out, basic_details
|
|
||||||
else:
|
|
||||||
return out
|
|
||||||
|
|
||||||
|
|
||||||
def remove_standard_fields(details):
|
def remove_standard_fields(details):
|
||||||
|
Loading…
Reference in New Issue
Block a user