fix: pos takes more time to add an item in the cart
This commit is contained in:
parent
f4d8457905
commit
6f3f2185ab
@ -164,7 +164,7 @@ def apply_pricing_rule(args, doc=None):
|
|||||||
args_copy.update(item)
|
args_copy.update(item)
|
||||||
data = get_pricing_rule_for_item(args_copy, item.get('price_list_rate'), doc=doc)
|
data = get_pricing_rule_for_item(args_copy, item.get('price_list_rate'), doc=doc)
|
||||||
out.append(data)
|
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))
|
out[0].update(get_serial_no_for_item(args_copy))
|
||||||
|
|
||||||
return out
|
return out
|
||||||
|
|||||||
@ -234,8 +234,10 @@ erpnext.pos.PointOfSale = class PointOfSale {
|
|||||||
this.update_item_in_frm(item, field, value)
|
this.update_item_in_frm(item, field, value)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
frappe.dom.unfreeze();
|
frappe.dom.unfreeze();
|
||||||
let items = this.frm.doc.items.map(item => item.idx);
|
frappe.run_serially([
|
||||||
if (items && items.length > 0 && items.indexOf(item.idx)) {
|
() => {
|
||||||
|
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 => {
|
this.frm.doc.items.forEach(item_row => {
|
||||||
// update cart
|
// update cart
|
||||||
this.on_qty_change(item_row);
|
this.on_qty_change(item_row);
|
||||||
@ -243,6 +245,9 @@ erpnext.pos.PointOfSale = class PointOfSale {
|
|||||||
} else {
|
} else {
|
||||||
this.on_qty_change(item);
|
this.on_qty_change(item);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
() => this.post_qty_change(item)
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -263,9 +268,20 @@ erpnext.pos.PointOfSale = class PointOfSale {
|
|||||||
.then(() => {
|
.then(() => {
|
||||||
this.frm.script_manager.trigger('qty', item.doctype, item.name)
|
this.frm.script_manager.trigger('qty', item.doctype, item.name)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.frm.doc.items.forEach(item => {
|
frappe.run_serially([
|
||||||
this.update_cart_data(item);
|
() => {
|
||||||
|
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) {
|
on_qty_change(item) {
|
||||||
frappe.run_serially([
|
frappe.run_serially([
|
||||||
() => this.update_cart_data(item),
|
() => 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) {
|
select_batch_and_serial_no(row) {
|
||||||
frappe.dom.unfreeze();
|
frappe.dom.unfreeze();
|
||||||
|
|
||||||
@ -304,7 +327,8 @@ erpnext.pos.PointOfSale = class PointOfSale {
|
|||||||
frappe.model.clear_doc(item.doctype, item.name);
|
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) {
|
update_cart_data(item) {
|
||||||
this.cart.add_item(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();
|
frappe.dom.unfreeze();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -974,7 +995,6 @@ class POSCart {
|
|||||||
$item.appendTo(this.$cart_items);
|
$item.appendTo(this.$cart_items);
|
||||||
}
|
}
|
||||||
this.highlight_item(item.item_code);
|
this.highlight_item(item.item_code);
|
||||||
this.scroll_to_item(item.item_code);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
update_item(item) {
|
update_item(item) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user