Onload works on New but not on Make

Hi,

I am trying to set the ‘naming series’ based on a field, which is linked to the Company DT.

If I create New Purchase Order, there is no problem. But when I am from Supplier Quotation and click on Make >> Purchase Order, the ‘naming series’ isn’t fetched.

frappe.ui.form.on(“Purchase Order”, {
onload: function(frm) {
// this function is called when page load
cur_frm.add_fetch(‘company’,‘purchase_order_naming_series’,‘naming_series’)
cur_frm.add_fetch(‘company’,‘default_letter_head’,‘letter_head’)
}
});

Is there another trigger for any DT that is created from the Make button?

Thanks!

@mulyadi-agtechsg,

naming_series field has a property No Copy enabled so it will not be copied when you click on Make or create a duplicate Purchase Order from existing one

@makarand_b

I have tried setting No Copy to disable. It is the same. This is my full custom script.

frappe.ui.form.on(“Purchase Order”, {
onload: function(frm) {
// this function is called when page load
cur_frm.add_fetch(‘company’,‘purchase_order_naming_series’,‘naming_series’)
cur_frm.add_fetch(‘company’,‘default_letter_head’,‘letter_head’)
}
});

frappe.ui.form.on(“Purchase Order”, {
company: function(frm) {
// this function is called when the value of company is changed.
cur_frm.add_fetch(‘company’,‘purchase_order_naming_series’,‘naming_series’)
cur_frm.add_fetch(‘company’,‘default_letter_head’,‘letter_head’)
}
});

@mulyadi-agtechsg,

Naming Series is select field so make sure that both Purchase Order and Company have the same Naming Series Options

@makarand_b

I checked that too.

I am wondering why the 2nd part of script works but the 1st part of script didn’t.

Thanks.