From 6f1d012b65c7969c84ded70f4675e8af5f589756 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Tue, 4 Oct 2016 12:18:59 +0530 Subject: [PATCH] [Fix] Multi company issue for POS --- erpnext/accounts/doctype/sales_invoice/pos.py | 1 + erpnext/accounts/page/pos/pos.js | 10 +++++----- erpnext/stock/get_item_details.py | 5 +++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/pos.py b/erpnext/accounts/doctype/sales_invoice/pos.py index 5336b5452c..70e7c189bd 100644 --- a/erpnext/accounts/doctype/sales_invoice/pos.py +++ b/erpnext/accounts/doctype/sales_invoice/pos.py @@ -15,6 +15,7 @@ def get_pos_data(): doc = frappe.new_doc('Sales Invoice') doc.is_pos = 1; pos_profile = get_pos_profile(doc.company) or {} + if not doc.company: doc.company = pos_profile.get('company') doc.update_stock = pos_profile.get('update_stock') if pos_profile.get('name'): diff --git a/erpnext/accounts/page/pos/pos.js b/erpnext/accounts/page/pos/pos.js index 247d5ac859..1c4d4103c7 100644 --- a/erpnext/accounts/page/pos/pos.js +++ b/erpnext/accounts/page/pos/pos.js @@ -106,7 +106,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ me.get_data_from_server(function(){ me.load_data(false); me.make_customer(); - me.make_item_list(); + me.make_item_list(false); me.set_missing_values(); }) }); @@ -275,7 +275,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ make: function() { this.make_search(); this.make_customer(); - this.make_item_list(); + this.make_item_list(true); this.make_discount_field() }, @@ -296,7 +296,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ this.search.$input.on("keyup", function() { setTimeout(function() { me.items = me.get_items(); - me.make_item_list(); + me.make_item_list(false); }, 1000); }); @@ -369,7 +369,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ } }, - make_item_list: function() { + make_item_list: function(index_search) { var me = this; if(!this.price_list) { msgprint(__("Price List not found or disabled")); @@ -383,7 +383,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ if (this.items) { $.each(this.items, function(index, obj) { - if(index < 16){ + if(!index_search || index < 16){ $(frappe.render_template("pos_item", { item_code: obj.name, item_price: format_currency(obj.price_list_rate, obj.currency), diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index 1e3bd8a209..e5dd7350e3 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -328,10 +328,11 @@ def get_pos_profile_item_details(company, args, pos_profile=None): @frappe.whitelist() def get_pos_profile(company): + condition = "and company = '%s'"%(company) if company else '' pos_profile = frappe.db.sql("""select * from `tabPOS Profile` where user = %s - and company = %s""", (frappe.session['user'], company), as_dict=1) + {cond}""".format(cond=condition), (frappe.session['user']), as_dict=1) - if not pos_profile: + if not pos_profile and company: pos_profile = frappe.db.sql("""select * from `tabPOS Profile` where ifnull(user,'') = '' and company = %s""", company, as_dict=1)