Hi all,
How can i filter Customers based on Party Account (accounts) by company…
Using frappe.listview_settings[‘Customer’] = {
filters: [[“company”, “=”, ‘ABC’]]
}
Returns Company field does not exist
filters: [{‘<Child Table Doctype(Party Account)>.company’: ‘ABC’}]
Does not work.
Thanks for the support.
ERPNext: v15.0.0 (version-15)
Frappe Framework: v15.0.0 (version-15)
This works. But filter takes Company (Allowed To Transact With). I couldn’t find the field
frappe.listview_settings['Customer'] = {
onload: function(frm) {
frappe.route_options = {
'company': ['=', "Demo Company" ]
};
}}
Hi thank you. I have come to that solution also but the issue is that if i have user permissions set for default company (ABC) and if in accounts company field is set with companies CDE, FGT and ABC it is not shown!
Actually, i thought that because User Permissions is set it would be applied on Customers and Suppliers but not.
By the end what I’m trying is to have User Permissions set on Customers and Supplier’s if Permission set for Company.
I saw on list_view that if i set the filter manually, filters will be [‘Party Account’, ‘company’, ‘=’, ‘ABC’, false] but still trying to find out how the system processes…
Hi all,
Managed to do the filter…
Actually, what i needed was if User has 1 Company on User Permissions means should show only Customers, Suppliers based on this Permission.
So, to achieve i have added the below:
//TRying to filter based on frappe.defaults.get_user_default
if (frappe.defaults.get_user_default) {
console.log('TEM FILTRO PARA USUARIO....');
console.log(frappe.defaults.get_user_default('Company'));
console.log(frappe.defaults.get_user_default('company'));
console.log('permissoes');
console.log(frappe.defaults.get_user_permissions(frappe.session.user));
console.log(' ', frappe.defaults.get_user_permissions(frappe.session.user)['Company']);
console.log('emp ', frappe.defaults.get_user_permissions(frappe.session.user).Company);
if (frappe.defaults.get_user_permissions(frappe.session.user).Company && frappe.defaults.get_user_permissions(frappe.session.user).Company.length == 1) {
console.log('Faz o filtro....');
frappe.listview_settings['Customer'] = {
filters: [["Party Account", "company", "=", frappe.defaults.get_user_permissions(frappe.session.user)['Company'][0]['doc'], true]],
refresh: function(listview) {
if (listview.filters.length == 0) {
//Filter based on User permissions...
listview.filters = [["Party Account", "company", "=", frappe.defaults.get_user_permissions(frappe.session.user)['Company'][0]['doc'], true]];
listview.filter_area.add(listview.filters);
} else {
//Filter again...
listview.filter_area.set(listview.filters);
}
}
};
}
}