Hi there,
Versions No.
I was trying to learn the development of scirpt report from source code, have come across some problems understanding in Accounts Receivable report.
The source code in GitHub link is here: erpnext/accounts_receivable.js at develop · frappe/erpnext · GitHub
From Line 154, there were 4 filters (tax_id, customer_name, payment_terms[catch spelling error on ‘label’ attrubite], credit_limit) that have set ‘hidden’ as 1 which works.
{
"fieldname":"tax_id",
"label": __("Tax Id"),
"fieldtype": "Data",
"hidden": 1
},
{
"fieldname":"customer_name",
"label": __("Customer Name"),
"fieldtype": "Data",
"hidden": 1
},
{
"fieldname":"payment_terms",
"label": __("Payment Tems"),
"fieldtype": "Data",
"hidden": 1
},
{
"fieldname":"credit_limit",
"label": __("Credit Limit"),
"fieldtype": "Currency",
"hidden": 1
}
But if you look at Line 80, there is a trigger function when customer field got a change then it will set the filter value for above filters so that these 4 filters should be shown to the users.
if (customer) {
frappe.db.get_value('Customer', customer, ["tax_id", "customer_name", "payment_terms"], function(value) {
frappe.query_report.set_filter_value('tax_id', value["tax_id"]);
frappe.query_report.set_filter_value('customer_name', value["customer_name"]);
frappe.query_report.set_filter_value('payment_terms', value["payment_terms"]);
});
frappe.db.get_value('Customer Credit Limit', {'parent': customer, 'company': company},
["credit_limit"], function(value) {
if (value) {
frappe.query_report.set_filter_value('credit_limit', value["credit_limit"]);
}
}, "Customer");
But I tried on a development ERPNext, which doesn’t show these 4 fields when I choose a customer.
Pictures below:
I also tried on my custom script report which has the same problem.
I am not sure if I miss anything or is this a potential bug?
It would be great if someone could kindly help me out.
Thank you in advance.