From f17b7b5ee9718e1265a73c1ae1a1f566a64dbc3f Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 23 May 2025 09:49:51 +0530 Subject: [PATCH] fix: skip last purchase rate for free item (backport #47693) (#47696) 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 259c262d0d7..54f00417a89 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)