From 6887cedaeaeea8998bc968d4eef467202fd36463 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Thu, 26 Oct 2017 14:34:15 +0530 Subject: [PATCH] [fix] item qty trigger (#11349) --- .../page/point_of_sale/point_of_sale.js | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/erpnext/selling/page/point_of_sale/point_of_sale.js b/erpnext/selling/page/point_of_sale/point_of_sale.js index e23dcdbc95..196bb960df 100644 --- a/erpnext/selling/page/point_of_sale/point_of_sale.js +++ b/erpnext/selling/page/point_of_sale/point_of_sale.js @@ -208,7 +208,9 @@ erpnext.pos.PointOfSale = class PointOfSale { this.update_item_in_frm(item) .then(() => { // update cart - this.remove_item_from_cart(item); + if (item.qty === 0) { + frappe.model.clear_doc(item.doctype, item.name); + } this.update_cart_data(item); }); }, true); @@ -227,22 +229,18 @@ erpnext.pos.PointOfSale = class PointOfSale { } if (field) { - frappe.model.set_value(item.doctype, item.name, field, value); + return frappe.model.set_value(item.doctype, item.name, field, value) + .then(() => this.frm.script_manager.trigger('qty', item.doctype, item.name)) + .then(() => { + console.log(item.qty, item.amount); + + if (field === 'qty' && item.qty === 0) { + frappe.model.clear_doc(item.doctype, item.name); + } + }) } - return this.frm.script_manager - .trigger('qty', item.doctype, item.name) - .then(() => { - if (field === 'qty') { - this.remove_item_from_cart(item); - } - }); - } - - remove_item_from_cart(item) { - if (item.qty === 0) { - frappe.model.clear_doc(item.doctype, item.name); - } + return Promise.resolve(); } make_payment_modal() {