How is shipping_address_display linked to shipping_address contents in a PO Form?

I’m tying to create a custom Address field in a PO form and then display the selected address text on the Form.
I’ve looked at the example by navigating to Customize Form, select Enter Form Type: Purchase Order and Default Print Format: Drop Shipping Format.PO Drop Shipping. There is a field (Select Shipping Address, Link, shipping_address, Address) that is followed by a read only field Shipping Address, Small Text, shipping_address_display

How is “Shipping Address” configured so that it takes the text from the selected “Select Shipping Address”
I’m trying to add 2 similar fields for a “Billing Address” but I can not manage to display the address of the selected “Select Billing Address” as the “Billing Address” field I can’t find any documentation on how this mechanism works.

@s_list,

You can use the frappe.utils.get_address_display to get and set the address using address template.

e.g. erpnext.utils.get_address_display(frm, address_field, address_display_field)

where address_field is Address Link field and address_display_field is field where you want to display the address.

Thanks,
Makarand

Please excuse my ignorance but how and where do I call the script frappe.utils.get_address_display from?

Additionally, where should I look to see how the built-in Drop Shipping Format calls get_address_display script in order to link shipping_address_display to shipping_address as an example.

@s_list,

You will need create the custom script for the Purchase Order

e.g.

frappe.ui.form.on("Purchase Order", {
	custom_address_field: function(frm) {
		erpnext.utils.get_address_display(this.frm, "custom_address_field", "custom_address_field_display");
	}
});

Thanks, Makarand

1 Like