mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-26 00:14:50 +00:00
Merge pull request #6537 from rohitwaghchaure/pos_multi_company_issue
[Fix] Multi company issue for POS
This commit is contained in:
@@ -15,6 +15,7 @@ def get_pos_data():
|
|||||||
doc = frappe.new_doc('Sales Invoice')
|
doc = frappe.new_doc('Sales Invoice')
|
||||||
doc.is_pos = 1;
|
doc.is_pos = 1;
|
||||||
pos_profile = get_pos_profile(doc.company) or {}
|
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')
|
doc.update_stock = pos_profile.get('update_stock')
|
||||||
|
|
||||||
if pos_profile.get('name'):
|
if pos_profile.get('name'):
|
||||||
|
|||||||
@@ -106,11 +106,15 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
me.get_data_from_server(function(){
|
me.get_data_from_server(function(){
|
||||||
me.load_data(false);
|
me.load_data(false);
|
||||||
me.make_customer();
|
me.make_customer();
|
||||||
me.make_item_list();
|
me.make_item_list(true);
|
||||||
me.set_missing_values();
|
me.set_missing_values();
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.page.add_menu_item(__("Sync Offline Invoices"), function(){
|
||||||
|
me.sync_sales_invoice()
|
||||||
|
});
|
||||||
|
|
||||||
this.page.add_menu_item(__("POS Profile"), function() {
|
this.page.add_menu_item(__("POS Profile"), function() {
|
||||||
frappe.set_route('List', 'POS Profile');
|
frappe.set_route('List', 'POS Profile');
|
||||||
});
|
});
|
||||||
@@ -275,7 +279,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
make: function() {
|
make: function() {
|
||||||
this.make_search();
|
this.make_search();
|
||||||
this.make_customer();
|
this.make_customer();
|
||||||
this.make_item_list();
|
this.make_item_list(true);
|
||||||
this.make_discount_field()
|
this.make_discount_field()
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -296,7 +300,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
this.search.$input.on("keyup", function() {
|
this.search.$input.on("keyup", function() {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
me.items = me.get_items();
|
me.items = me.get_items();
|
||||||
me.make_item_list();
|
me.make_item_list(false);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -369,7 +373,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
make_item_list: function() {
|
make_item_list: function(index_search) {
|
||||||
var me = this;
|
var me = this;
|
||||||
if(!this.price_list) {
|
if(!this.price_list) {
|
||||||
msgprint(__("Price List not found or disabled"));
|
msgprint(__("Price List not found or disabled"));
|
||||||
@@ -383,7 +387,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
|
|
||||||
if (this.items) {
|
if (this.items) {
|
||||||
$.each(this.items, function(index, obj) {
|
$.each(this.items, function(index, obj) {
|
||||||
if(index < 16){
|
if(!index_search || index < 16){
|
||||||
$(frappe.render_template("pos_item", {
|
$(frappe.render_template("pos_item", {
|
||||||
item_code: obj.name,
|
item_code: obj.name,
|
||||||
item_price: format_currency(obj.price_list_rate, obj.currency),
|
item_price: format_currency(obj.price_list_rate, obj.currency),
|
||||||
|
|||||||
@@ -328,10 +328,11 @@ def get_pos_profile_item_details(company, args, pos_profile=None):
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_pos_profile(company):
|
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
|
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`
|
pos_profile = frappe.db.sql("""select * from `tabPOS Profile`
|
||||||
where ifnull(user,'') = '' and company = %s""", company, as_dict=1)
|
where ifnull(user,'') = '' and company = %s""", company, as_dict=1)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user