Merge pull request #7180 from rohitwaghchaure/pos_profile_issue
[Fix] Item group missing in the POS profile
This commit is contained in:
commit
f93cbe9a51
@ -26,30 +26,6 @@ frappe.ui.form.on("POS Profile", "onload", function(frm) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
frappe.ui.form.on("POS Profile", {
|
|
||||||
setup: function(frm) {
|
|
||||||
frm.trigger("get_query_for_groups")
|
|
||||||
},
|
|
||||||
|
|
||||||
get_query_for_groups: function(frm) {
|
|
||||||
frm.fields_dict['item_groups'].grid.get_field('item_group').get_query = function(frm, cdt, cdn) {
|
|
||||||
return{
|
|
||||||
filters: {
|
|
||||||
'is_group': 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
frm.fields_dict['customer_groups'].grid.get_field('customer_group').get_query = function(frm, cdt, cdn) {
|
|
||||||
return{
|
|
||||||
filters: {
|
|
||||||
'is_group': 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// Income Account
|
// Income Account
|
||||||
// --------------------------------
|
// --------------------------------
|
||||||
cur_frm.fields_dict['income_account'].get_query = function(doc,cdt,cdn) {
|
cur_frm.fields_dict['income_account'].get_query = function(doc,cdt,cdn) {
|
||||||
|
|||||||
@ -115,9 +115,9 @@ def get_items_list(pos_profile):
|
|||||||
item_groups = []
|
item_groups = []
|
||||||
if pos_profile.get('item_groups'):
|
if pos_profile.get('item_groups'):
|
||||||
# Get items based on the item groups defined in the POS profile
|
# Get items based on the item groups defined in the POS profile
|
||||||
|
for d in pos_profile.get('item_groups'):
|
||||||
cond = "item_group in (%s)"%(', '.join(['%s']*len(pos_profile.get('item_groups'))))
|
item_groups.extend(get_child_nodes('Item Group', d.item_group))
|
||||||
item_groups = [d.item_group for d in pos_profile.get('item_groups')]
|
cond = "item_group in (%s)"%(', '.join(['%s']*len(item_groups)))
|
||||||
|
|
||||||
return frappe.db.sql("""
|
return frappe.db.sql("""
|
||||||
select
|
select
|
||||||
@ -135,14 +135,19 @@ def get_customers_list(pos_profile):
|
|||||||
customer_groups = []
|
customer_groups = []
|
||||||
if pos_profile.get('customer_groups'):
|
if pos_profile.get('customer_groups'):
|
||||||
# Get customers based on the customer groups defined in the POS profile
|
# Get customers based on the customer groups defined in the POS profile
|
||||||
|
for d in pos_profile.get('customer_groups'):
|
||||||
cond = "customer_group in (%s)"%(', '.join(['%s']*len(pos_profile.get('customer_groups'))))
|
customer_groups.extend(get_child_nodes('Customer Group', d.customer_group))
|
||||||
customer_groups = [d.customer_group for d in pos_profile.get('customer_groups')]
|
cond = "customer_group in (%s)"%(', '.join(['%s']*len(customer_groups)))
|
||||||
|
|
||||||
return frappe.db.sql(""" select name, customer_name, customer_group,
|
return frappe.db.sql(""" select name, customer_name, customer_group,
|
||||||
territory from tabCustomer where disabled = 0
|
territory from tabCustomer where disabled = 0
|
||||||
and {cond}""".format(cond=cond), tuple(customer_groups), as_dict=1) or {}
|
and {cond}""".format(cond=cond), tuple(customer_groups), as_dict=1) or {}
|
||||||
|
|
||||||
|
def get_child_nodes(group_type, root):
|
||||||
|
lft, rgt = frappe.db.get_value(group_type, root, ["lft", "rgt"])
|
||||||
|
return frappe.db.sql_list(""" Select name from `tab{tab}` where
|
||||||
|
lft >= {lft} and rgt <= {rgt}""".format(tab=group_type, lft=lft, rgt=rgt))
|
||||||
|
|
||||||
def get_serial_no_data(pos_profile, company):
|
def get_serial_no_data(pos_profile, company):
|
||||||
# get itemwise serial no data
|
# get itemwise serial no data
|
||||||
# example {'Nokia Lumia 1020': {'SN0001': 'Pune'}}
|
# example {'Nokia Lumia 1020': {'SN0001': 'Pune'}}
|
||||||
@ -240,8 +245,7 @@ def make_invoice(doc_list):
|
|||||||
|
|
||||||
for docs in doc_list:
|
for docs in doc_list:
|
||||||
for name, doc in docs.items():
|
for name, doc in docs.items():
|
||||||
if not frappe.db.exists('Sales Invoice',
|
if not frappe.db.exists('Sales Invoice', {'offline_pos_name': name}):
|
||||||
{'offline_pos_name': name, 'docstatus': ("<", "2")}):
|
|
||||||
validate_records(doc)
|
validate_records(doc)
|
||||||
si_doc = frappe.new_doc('Sales Invoice')
|
si_doc = frappe.new_doc('Sales Invoice')
|
||||||
si_doc.offline_pos_name = name
|
si_doc.offline_pos_name = name
|
||||||
@ -286,6 +290,7 @@ def submit_invoice(si_doc, name):
|
|||||||
try:
|
try:
|
||||||
si_doc.insert()
|
si_doc.insert()
|
||||||
si_doc.submit()
|
si_doc.submit()
|
||||||
|
frappe.db.commit()
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
if frappe.message_log: frappe.message_log.pop()
|
if frappe.message_log: frappe.message_log.pop()
|
||||||
frappe.db.rollback()
|
frappe.db.rollback()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user