From 1f1cb338feea1061a41bc226f5aa57cb3428d9ab Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Sat, 24 May 2025 17:17:09 +0530 Subject: [PATCH] fix: skip last purchase rate for free item (backport #47693) (#47695) fix: skip last purchase rate for free item (#47693) (cherry picked from commit c3b17024bd8c024c91dbde578b979dc00de83b33) Co-authored-by: rohitwaghchaure --- erpnext/buying/utils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/erpnext/buying/utils.py b/erpnext/buying/utils.py index 8223917792c..9ee8868e2c7 100644 --- a/erpnext/buying/utils.py +++ b/erpnext/buying/utils.py @@ -20,6 +20,9 @@ def update_last_purchase_rate(doc, is_submit) -> None: this_purchase_date = getdate(doc.get("posting_date") or doc.get("transaction_date")) for d in doc.get("items"): + if d.get("is_free_item"): + continue + # get last purchase details last_purchase_details = get_last_purchase_details(d.item_code, doc.name)