Merge pull request #17141 from rohitwaghchaure/incorrect_pos_profile_selected_if
fix: incorrect auto POS profile selected in the sales invoice
This commit is contained in:
commit
e334413b34
@ -446,16 +446,15 @@ erpnext.pos.PointOfSale = class PointOfSale {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setup_company() {
|
setup_company() {
|
||||||
this.company = frappe.sys_defaults.company;
|
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
if(!this.company) {
|
if(!frappe.sys_defaults.company) {
|
||||||
frappe.prompt({fieldname:"company", options: "Company", fieldtype:"Link",
|
frappe.prompt({fieldname:"company", options: "Company", fieldtype:"Link",
|
||||||
label: __("Select Company"), reqd: 1}, (data) => {
|
label: __("Select Company"), reqd: 1}, (data) => {
|
||||||
this.company = data.company;
|
this.company = data.company;
|
||||||
resolve(this.company);
|
resolve(this.company);
|
||||||
}, __("Select Company"));
|
}, __("Select Company"));
|
||||||
} else {
|
} else {
|
||||||
resolve(this.company);
|
resolve();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -509,7 +508,9 @@ erpnext.pos.PointOfSale = class PointOfSale {
|
|||||||
}
|
}
|
||||||
|
|
||||||
set_pos_profile_data() {
|
set_pos_profile_data() {
|
||||||
this.frm.doc.company = this.company;
|
if (this.company) {
|
||||||
|
this.frm.doc.company = this.company;
|
||||||
|
}
|
||||||
|
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
return this.frm.call({
|
return this.frm.call({
|
||||||
|
@ -606,28 +606,39 @@ def get_pos_profile_item_details(company, args, pos_profile=None, update_data=Fa
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_pos_profile(company, pos_profile=None, user=None):
|
def get_pos_profile(company, pos_profile=None, user=None):
|
||||||
if pos_profile:
|
if pos_profile: return frappe.get_cached_doc('POS Profile', pos_profile)
|
||||||
return frappe.get_cached_doc('POS Profile', pos_profile)
|
|
||||||
|
|
||||||
if not user:
|
if not user:
|
||||||
user = frappe.session['user']
|
user = frappe.session['user']
|
||||||
|
|
||||||
|
condition = "pfu.user = %(user)s AND pfu.default=1"
|
||||||
|
if user and company:
|
||||||
|
condition = "pfu.user = %(user)s AND pf.company = %(company)s AND pfu.default=1"
|
||||||
|
|
||||||
pos_profile = frappe.db.sql("""SELECT pf.*
|
pos_profile = frappe.db.sql("""SELECT pf.*
|
||||||
FROM
|
FROM
|
||||||
`tabPOS Profile` pf LEFT JOIN `tabPOS Profile User` pfu
|
`tabPOS Profile` pf LEFT JOIN `tabPOS Profile User` pfu
|
||||||
ON
|
ON
|
||||||
pf.name = pfu.parent
|
pf.name = pfu.parent
|
||||||
WHERE
|
WHERE
|
||||||
(
|
{cond} AND pf.disabled = 0
|
||||||
(pfu.user = %(user)s AND pf.company = %(company)s AND pfu.default=1)
|
""".format(cond = condition), {
|
||||||
OR (pfu.user = %(user)s AND pfu.default=1)
|
|
||||||
OR (ifnull(pfu.user, '') = '' AND pf.company = %(company)s)
|
|
||||||
) AND pf.disabled = 0
|
|
||||||
""", {
|
|
||||||
'user': user,
|
'user': user,
|
||||||
'company': company
|
'company': company
|
||||||
}, as_dict=1)
|
}, as_dict=1)
|
||||||
|
|
||||||
|
if not pos_profile and company:
|
||||||
|
pos_profile = frappe.db.sql("""SELECT pf.*
|
||||||
|
FROM
|
||||||
|
`tabPOS Profile` pf LEFT JOIN `tabPOS Profile User` pfu
|
||||||
|
ON
|
||||||
|
pf.name = pfu.parent
|
||||||
|
WHERE
|
||||||
|
pf.company = %(company)s AND pf.disabled = 0
|
||||||
|
""", {
|
||||||
|
'company': company
|
||||||
|
}, as_dict=1)
|
||||||
|
|
||||||
return pos_profile and pos_profile[0] or None
|
return pos_profile and pos_profile[0] or None
|
||||||
|
|
||||||
def get_serial_nos_by_fifo(args, sales_order=None):
|
def get_serial_nos_by_fifo(args, sales_order=None):
|
||||||
|
Loading…
Reference in New Issue
Block a user