Help with adding company abbreviation to production orders

I have a multi-company setup and would like to distinguish documents by their document numbers. I’m using company abbreviation to do so. For example: Sales Orders would be SO-XX-###, where XX would be the company abbreviation.

I’m trying to do this for Production Order. It works okay if I customise it this way: I use the naming series and customising the form.
Naming Series: PRO-.co_abbr.-
Customise Form - Production Order: LABEL: co_abbr, TYPE: Data, NAME: co_abbr, OPTIONS: company.abbr

But, this only works when I create a new Production Order using the form/webui. The problem is that when I create production order from within a sales order, or use the production planning tool. The production order created are PRO-co_abbr-001, PRO-co_abbr-002, etc…

I tried to create a custom script within Production Order: cur_frm.add_fetch(“company”, “abbr”, “company_abbr”);

But that doesn’t seem to do the trick either. Any suggestions?

Thank you in advance for any help.

The input value for abbreviation will only be available from the form view. Given the approach, you will have to standardize the practice of creation Production Order from form view only.

Did you try Document Title for referencing purpose? If that works, you can give it preference over Naming Series.

https://erpnext.org/docs/user/manual/en/customize-erpnext/document-title