Merge pull request #17093 from rohitwaghchaure/improved_online_pos_performance
fix: pos takes more time to add an item in the cart
This commit is contained in:
commit
235dc4fb62
@ -164,7 +164,7 @@ def apply_pricing_rule(args, doc=None):
|
||||
args_copy.update(item)
|
||||
data = get_pricing_rule_for_item(args_copy, item.get('price_list_rate'), doc=doc)
|
||||
out.append(data)
|
||||
if set_serial_nos_based_on_fifo and not args.get('is_return'):
|
||||
if not item.get("serial_no") and set_serial_nos_based_on_fifo and not args.get('is_return'):
|
||||
out[0].update(get_serial_no_for_item(args_copy))
|
||||
|
||||
return out
|
||||
|
@ -234,15 +234,20 @@ erpnext.pos.PointOfSale = class PointOfSale {
|
||||
this.update_item_in_frm(item, field, value)
|
||||
.then(() => {
|
||||
frappe.dom.unfreeze();
|
||||
let items = this.frm.doc.items.map(item => item.idx);
|
||||
if (items && items.length > 0 && items.indexOf(item.idx)) {
|
||||
this.frm.doc.items.forEach(item_row => {
|
||||
// update cart
|
||||
this.on_qty_change(item_row);
|
||||
});
|
||||
} else {
|
||||
this.on_qty_change(item);
|
||||
}
|
||||
frappe.run_serially([
|
||||
() => {
|
||||
let items = this.frm.doc.items.map(item => item.name);
|
||||
if (items && items.length > 0 && items.includes(item.name)) {
|
||||
this.frm.doc.items.forEach(item_row => {
|
||||
// update cart
|
||||
this.on_qty_change(item_row);
|
||||
});
|
||||
} else {
|
||||
this.on_qty_change(item);
|
||||
}
|
||||
},
|
||||
() => this.post_qty_change(item)
|
||||
]);
|
||||
});
|
||||
}
|
||||
return;
|
||||
@ -263,9 +268,20 @@ erpnext.pos.PointOfSale = class PointOfSale {
|
||||
.then(() => {
|
||||
this.frm.script_manager.trigger('qty', item.doctype, item.name)
|
||||
.then(() => {
|
||||
this.frm.doc.items.forEach(item => {
|
||||
this.update_cart_data(item);
|
||||
});
|
||||
frappe.run_serially([
|
||||
() => {
|
||||
let items = this.frm.doc.items.map(i => i.name);
|
||||
if (items && items.length > 0 && items.includes(item.name)) {
|
||||
this.frm.doc.items.forEach(item_row => {
|
||||
// update cart
|
||||
this.on_qty_change(item_row);
|
||||
});
|
||||
} else {
|
||||
this.on_qty_change(item);
|
||||
}
|
||||
},
|
||||
() => this.post_qty_change(item)
|
||||
]);
|
||||
});
|
||||
});
|
||||
},
|
||||
@ -286,10 +302,17 @@ erpnext.pos.PointOfSale = class PointOfSale {
|
||||
on_qty_change(item) {
|
||||
frappe.run_serially([
|
||||
() => this.update_cart_data(item),
|
||||
() => this.set_form_action()
|
||||
]);
|
||||
}
|
||||
|
||||
post_qty_change(item) {
|
||||
this.cart.update_taxes_and_totals();
|
||||
this.cart.update_grand_total();
|
||||
this.cart.update_qty_total();
|
||||
this.cart.scroll_to_item(item.item_code);
|
||||
this.set_form_action();
|
||||
}
|
||||
|
||||
select_batch_and_serial_no(row) {
|
||||
frappe.dom.unfreeze();
|
||||
|
||||
@ -304,7 +327,8 @@ erpnext.pos.PointOfSale = class PointOfSale {
|
||||
frappe.model.clear_doc(item.doctype, item.name);
|
||||
}
|
||||
},
|
||||
() => this.update_cart_data(item)
|
||||
() => this.update_cart_data(item),
|
||||
() => this.post_qty_change(item)
|
||||
]);
|
||||
});
|
||||
})
|
||||
@ -321,9 +345,6 @@ erpnext.pos.PointOfSale = class PointOfSale {
|
||||
|
||||
update_cart_data(item) {
|
||||
this.cart.add_item(item);
|
||||
this.cart.update_taxes_and_totals();
|
||||
this.cart.update_grand_total();
|
||||
this.cart.update_qty_total();
|
||||
frappe.dom.unfreeze();
|
||||
}
|
||||
|
||||
@ -974,7 +995,6 @@ class POSCart {
|
||||
$item.appendTo(this.$cart_items);
|
||||
}
|
||||
this.highlight_item(item.item_code);
|
||||
this.scroll_to_item(item.item_code);
|
||||
}
|
||||
|
||||
update_item(item) {
|
||||
|
Loading…
Reference in New Issue
Block a user