From b00c16470dc9f8d7997dc98fa16042bd23e8218d Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Fri, 29 Mar 2019 13:34:39 +0530 Subject: [PATCH] fix: POS items not loading --- erpnext/selling/page/point_of_sale/point_of_sale.js | 13 +++++++++---- erpnext/selling/page/point_of_sale/point_of_sale.py | 11 ++++------- 2 files changed, 13 insertions(+), 11 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 c54430fd56..f5e21d14cd 100644 --- a/erpnext/selling/page/point_of_sale/point_of_sale.js +++ b/erpnext/selling/page/point_of_sale/point_of_sale.js @@ -251,7 +251,15 @@ erpnext.pos.PointOfSale = class PointOfSale { frappe.flags.hide_serial_batch_dialog = true; frappe.run_serially([ - () => this.frm.script_manager.trigger('item_code', item.doctype, item.name), + () => { + this.frm.script_manager.trigger('item_code', item.doctype, item.name) + .then(() => { + this.frm.script_manager.trigger('qty', item.doctype, item.name) + .then(() => { + this.update_cart_data(item); + }); + }); + }, () => { const show_dialog = item.has_serial_no || item.has_batch_no; @@ -261,9 +269,6 @@ erpnext.pos.PointOfSale = class PointOfSale { (item.has_serial_no) || (item.actual_batch_qty != item.actual_qty)) ) { // check has serial no/batch no and update cart this.select_batch_and_serial_no(item); - } else { - // update cart - this.update_cart_data(item); } } ]); diff --git a/erpnext/selling/page/point_of_sale/point_of_sale.py b/erpnext/selling/page/point_of_sale/point_of_sale.py index ced6540e21..7c3cf5b039 100644 --- a/erpnext/selling/page/point_of_sale/point_of_sale.py +++ b/erpnext/selling/page/point_of_sale/point_of_sale.py @@ -29,7 +29,7 @@ def get_items(start, page_length, price_list, item_group, search_value="", pos_p batch_no = data.get("batch_no") if data.get("batch_no") else "" barcode = data.get("barcode") if data.get("barcode") else "" - item_code, condition = get_conditions(item_code, serial_no, batch_no, barcode) + condition = get_conditions(item_code, serial_no, batch_no, barcode) if pos_profile: condition += get_item_group_condition(pos_profile) @@ -86,7 +86,6 @@ def get_items(start, page_length, price_list, item_group, search_value="", pos_p and {condition} limit {start}, {page_length}""".format (start=start,page_length=page_length,lft=lft, rgt=rgt, condition=condition), { - 'item_code': item_code, 'price_list': price_list, 'warehouse': warehouse } , as_dict=1) @@ -133,12 +132,10 @@ def search_serial_or_batch_or_barcode_number(search_value): def get_conditions(item_code, serial_no, batch_no, barcode): if serial_no or batch_no or barcode: - return frappe.db.escape(item_code), "i.name = %(item_code)s" + return "i.name = {0}".format(frappe.db.escape(item_code)) - condition = """(i.name like %(item_code)s - or i.item_name like %(item_code)s)""" - - return frappe.db.escape('%' + item_code + '%'), condition + return """(i.name like {item_code} + or i.item_name like {item_code})""".format(item_code = frappe.db.escape('%' + item_code + '%')) def get_item_group_condition(pos_profile): cond = "and 1=1"