From 05810009907560b02509fcb43ae65319daa54e90 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Mon, 5 Dec 2022 17:59:02 +0530 Subject: [PATCH] fix: Remove free items --- erpnext/public/js/controllers/transaction.js | 25 ++++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 32268319f2..58d8de2499 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -1360,16 +1360,21 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe var item_list = []; $.each(this.frm.doc["items"] || [], function(i, d) { - if (d.item_code && !d.is_free_item) { - item_list.push({ - "doctype": d.doctype, - "name": d.name, - "item_code": d.item_code, - "pricing_rules": d.pricing_rules, - "parenttype": d.parenttype, - "parent": d.parent, - "price_list_rate": d.price_list_rate - }) + if (d.item_code) { + if (d.is_free_item) { + // Simply remove free items + me.frm.get_field("items").grid.grid_rows[i].remove(); + } else { + item_list.push({ + "doctype": d.doctype, + "name": d.name, + "item_code": d.item_code, + "pricing_rules": d.pricing_rules, + "parenttype": d.parenttype, + "parent": d.parent, + "price_list_rate": d.price_list_rate + }) + } } }); return this.frm.call({