fix: prevent multiple save on applying coupon code
This commit is contained in:
parent
f090e63e54
commit
d5fd8e0ba6
@ -170,20 +170,24 @@ erpnext.PointOfSale.Payment = class {
|
|||||||
});
|
});
|
||||||
|
|
||||||
frappe.ui.form.on('POS Invoice', 'coupon_code', (frm) => {
|
frappe.ui.form.on('POS Invoice', 'coupon_code', (frm) => {
|
||||||
if (!frm.doc.ignore_pricing_rule && frm.doc.coupon_code) {
|
if (frm.doc.coupon_code && !frm.applying_pos_coupon_code) {
|
||||||
frappe.run_serially([
|
if (!frm.doc.ignore_pricing_rule) {
|
||||||
() => frm.doc.ignore_pricing_rule=1,
|
frm.applying_pos_coupon_code = true
|
||||||
() => frm.trigger('ignore_pricing_rule'),
|
frappe.run_serially([
|
||||||
() => frm.doc.ignore_pricing_rule=0,
|
() => frm.doc.ignore_pricing_rule=1,
|
||||||
() => frm.trigger('apply_pricing_rule'),
|
() => frm.trigger('ignore_pricing_rule'),
|
||||||
() => frm.save(),
|
() => frm.doc.ignore_pricing_rule=0,
|
||||||
() => this.update_totals_section(frm.doc)
|
() => frm.trigger('apply_pricing_rule'),
|
||||||
]);
|
() => frm.save(),
|
||||||
} else if (frm.doc.ignore_pricing_rule && frm.doc.coupon_code) {
|
() => this.update_totals_section(frm.doc),
|
||||||
frappe.show_alert({
|
() => (frm.applying_pos_coupon_code = false)
|
||||||
message: __("Ignore Pricing Rule is enabled. Cannot apply coupon code."),
|
]);
|
||||||
indicator: "orange"
|
} else if (frm.doc.ignore_pricing_rule) {
|
||||||
});
|
frappe.show_alert({
|
||||||
|
message: __("Ignore Pricing Rule is enabled. Cannot apply coupon code."),
|
||||||
|
indicator: "orange"
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user