Hi
When I was handling frappe.call I received a wired issue. I got different result between frappe.call and bench console.
My function in whitelist
@frappe.whitelist()
def ecn_query(item_group,item_name,batch_id):
values={"item_group":item_group, "item_name":item_name, "batch_id":batch_id}
ret=[]
p=[]
if item_group=="ALL":
ret=frappe.db.sql(
"""
SELECT DISTINCT p.customer,p.customer_name
FROM `tabDelivery Note Item` AS c JOIN `tabDelivery Note` AS p
WHERE c.parent=p.name
""",values,as_dict=1,debug=1
)
elif item_name=="ALL" and item_group!="ALL":
p_char=item_group[:1]
p_row=frappe.db.get_list('Item',
filters={
'disabled': 0,
'item_group': ['like', p_char+'%']
},
fields=['item_name']
)
for i in p_row:
values={"item_name":i.item_name}
p+=frappe.db.sql(
"""
SELECT DISTINCT p.customer,p.customer_name
FROM `tabDelivery Note Item` AS c JOIN `tabDelivery Note` AS p
WHERE c.parent=p.name AND c.item_name=%(item_name)s
""",values,as_dict=1,debug=1)
for i in p:
if i not in ret:
ret.append(i)
else:
ret=frappe.db.sql(
"""
SELECT DISTINCT p.customer,p.customer_name
FROM `tabDelivery Note Item` AS c JOIN `tabDelivery Note` AS p
WHERE c.parent=p.name AND c.batch_no=%(batch_id)s AND c.item_name=%(item_name)s
""",values,as_dict=1,debug=1
)
return ret
if I run in bench console
I can see 2 objects customer and customer_name
but when i run my js, chrome console only show 1 object which is the first one customer like below.
I don’t know what i’m missing.
Thanks.