How can I use filters for customer?

Hello everyone.

I try to use filters for customer, but not working!.
Somebody help me please.

My code in Sales Order (sales_order.js) is:

frappe.ui.form.on("Sales Order", "onload", function(frm, cdt, cdn) {	
	cur_frm.fields_dict['customer'].get_query = function(doc, cdt, cdn) {
		return {
			filters:{'customer_name': "Client 0001"}
		}
	}
});

I found information about a problem by filtering customers in this way in the following post:

But I not sure how change the active filters for the customer doctype.

try below code

cur_frm.fields_dict.customer.get_query = function(doc) {
return {
filters: {
“customer_name”: “Client 0001”
}
}
};

Thank you for your reply, I tried the code, but even it does not work, this is a very peculiar problem because if I want to filter other data it works for example items.
This problem only happens with the customers, I do not know how to filter them.

This is the code that I have tried

frappe.ui.form.on("Sales Order", "onload", function(frm, cdt, cdn) {        	
	cur_frm.fields_dict.customer.get_query = function(doc) {
		return {
			filters: {
				"customer_name": "Client 0001"
			}
		}
	};
});

OK, problem solved. Now filter per field called gira in customers
We need to edit the file:
/home/frappe/frappe-bench/apps/erpnext/erpnext/controllers/queries.py -->Like this

Now we call this query like this in sales order (sales_order.js):

When I select a gira drop down, it filters all the customers that belong to it.

1 Like