From 4e347d835e86c644dfd2a0a6b955f0b4aa8e4713 Mon Sep 17 00:00:00 2001 From: Sanket322 Date: Thu, 23 Jan 2025 11:55:12 +0530 Subject: [PATCH] fix: remove applied pricing rule (cherry picked from commit 50223c6bec3e5a497034246945aa0188a415921b) --- erpnext/accounts/doctype/pricing_rule/pricing_rule.py | 2 -- erpnext/public/js/controllers/transaction.js | 11 +++++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py index 87d4d2a33e6..73cb2483811 100644 --- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py +++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py @@ -415,8 +415,6 @@ def get_pricing_rule_for_item(args, doc=None, for_validate=False): "parent": args.parent, "parenttype": args.parenttype, "child_docname": args.get("child_docname"), - "discount_percentage": args.get("discount_percentage") or 0.0, - "discount_amount": args.get("discount_amount") or 0.0, } ) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 09e52932d89..86c9ef46c78 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -1658,7 +1658,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe }, callback: function(r) { if (!r.exc && r.message) { - me.remove_pricing_rule(r.message, removed_pricing_rule); + me.remove_pricing_rule(r.message, removed_pricing_rule, item.name); me.calculate_taxes_and_totals(); if(me.frm.doc.apply_discount_on) me.frm.trigger("apply_discount_on"); } @@ -1937,7 +1937,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe }); } - remove_pricing_rule(item, removed_pricing_rule) { + remove_pricing_rule(item, removed_pricing_rule, row_name) { let me = this; const fields = ["discount_percentage", "discount_amount", "margin_rate_or_amount", "rate_with_margin"]; @@ -1976,6 +1976,13 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe me.trigger_price_list_rate(); } + else if(!item.is_free_item && row_name){ + me.frm.doc.items.forEach(d => { + if (d.name != row_name) return; + + Object.assign(d, item); + }); + } } trigger_price_list_rate() {