Creating Company-Specific Naming Series
In a multi-company environment, you may want each company to have its own document numbering sequence. For example, Sales Invoices created for different companies can follow separate naming series based on the company abbreviation.
For example:
- Company A: SINV-A-0001, SINV-A-0002, …
- Company B: SINV-B-0001, SINV-B-0002, …
- Company C: SINV-C-0001, SINV-C-0002, …
This can be achieved by fetching the company abbreviation into the document and using it in the naming series.
How It Works
ERPNext allows naming series to use values from document fields. By creating a custom field that stores the selected company’s abbreviation, the naming series can dynamically include that value whenever a new document is created.
Although this example uses Sales Invoice, the same approach can be applied to other documents such as Purchase Orders, Sales Orders, Delivery Notes, Purchase Invoices, and more.
Steps to Configure Company-Specific Naming Series
Step 1: Open Customize Form
Navigate to Customize Form and select the DocType for which you want to configure company-specific naming.
Example:
Customize Form → Sales Invoice
Step 2: Create a Custom Field for Company Abbreviation
Add a new field immediately below the Company field.
Configure the field as follows:
- Label: Abbr
- Fetch From:
company.abbr
The Fetch From property automatically retrieves the abbreviation from the selected Company record whenever a company is selected.
Optionally, enable the Hidden property if you do not want users to see this field on the form.
Step 3: Update the Naming Series
Within the same Customize Form, locate the Naming Series field and expand its configuration.
In the Options section, add a new naming pattern such as:
SINV-.abbr.-.####
Set this naming pattern as the default if required.
The placeholder .abbr. is automatically replaced with the value fetched from the Company document.
After making the changes, click Update to save the customization.
Result
When a new Sales Invoice is created and a Company is selected, ERPNext automatically fetches the company abbreviation and generates the document number accordingly.
For example:
- If the selected company abbreviation is A, the document name becomes SINV-A-0001.
- If the selected company abbreviation is B, the document name becomes SINV-B-0001.
- If the selected company abbreviation is C, the document name becomes SINV-C-0001.
Benefits
- Maintains separate document numbering for each company.
- Makes documents easier to identify based on the issuing company.
- Eliminates manual selection of different naming series.
- Supports multi-company environments while using a single ERPNext instance.
- Can be implemented without custom scripts by using field customization and dynamic naming.
Important Notes
- The Company DocType must have an abbreviation defined in the Abbr field.
- The custom field must correctly fetch
company.abbr; otherwise, the naming series cannot resolve the placeholder. - The placeholder name in the naming series must exactly match the custom field name.
- This approach works with any DocType that includes a Company field and supports configurable naming series.