From 00981206adc346badc92be97920b86f550a3167e Mon Sep 17 00:00:00 2001 From: Mohammad Hasnain Mohsin Rajan Date: Thu, 14 Jan 2021 19:23:18 +0530 Subject: [PATCH] fix: last purchase rate not updating when voucher cancelled if only one voucher is present (#24322) * fix: last purchase rate not updating * chore: use orm for updating Co-authored-by: Afshan <33727827+AfshanKhan@users.noreply.github.com> --- erpnext/buying/utils.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/erpnext/buying/utils.py b/erpnext/buying/utils.py index 47b48665b6..a73cb0d62e 100644 --- a/erpnext/buying/utils.py +++ b/erpnext/buying/utils.py @@ -35,9 +35,10 @@ def update_last_purchase_rate(doc, is_submit): frappe.throw(_("UOM Conversion factor is required in row {0}").format(d.idx)) # update last purchsae rate - if last_purchase_rate: - frappe.db.sql("""update `tabItem` set last_purchase_rate = %s where name = %s""", - (flt(last_purchase_rate), d.item_code)) + frappe.db.set_value('Item', d.item_code, 'last_purchase_rate', flt(last_purchase_rate)) + + + def validate_for_items(doc): items = []