Address in sales order

hi, when creating a new Sales Order, after choosing a customer, the address fields will be filled directly.
how can i create a custom script that will leave this field empty when selecting a specific customer?

frappe.ui.form.on(“Sales order”, “refresh”, function(frm, doctype, name)
cur_frm.get_field(“customer”).get_query = function(doc, cdt, cdn)
var item = frappe.get_doc(cdt, cdn);
var c = " ";
if (item.customer == “Clients Particulier”)
frm.set_value(“customer_address”, " ");



i tried this code but it didnt work

I’ve always wondered how the core system populates the address table, as the way the address field is formatted is rather stupid, couldn’t find out where they are executed really.

The reason why your code doesn’t work is because, there’s another subscript somewhere around the system where it automatically loads the address on that field. Because i’ve checked the Sales Order / Purchase Order / Quotation .js file and .py file to find out how the address field was generated, found none.

In the end, i had to totally hide the entire contacts module and associate each customer / supplier with their own customized column of address/contact details to be called directly on the "Customer / Supplier " doctype.

so if a customer has many address, based on what it will display one of them when selecting this customer for an order? even if none of all the addresses is selected as primary. so plz i need a help asap. When selecting this specific client, the Address field should remain empty.

This is a subscript that render address field.

Hi, I haven’t tried this but this should works.

frappe.ui.form.on('Sales Order', {
	// this will trigger if customer field change
	customer: function(frm) {
		// setting timeout for 2 sec to wait for frappe to fill address field
		// after 2 sec address field should be fill the we set it to blank
			function() {
				frm.set_value("customer_address", "");
			, 2000
1 Like

this helped me a lot, thank you! but i have one more question i am trying to modify this code in order to a add a condition on the name of the client, so it will be applied only to this specific client. can u help me plz

no one??