Naming Series by Entity

Is there anyone who has the experience that auditor requested the Naming Series of the documents must split by entity? Currently, there Naming Series are share among the entities, if you have more than one entities on the same site.


@CLU, you can use a custom script to determine de Naming Series, based on company, a sample for Item

frappe.ui.form.on("Item", "validate", function(doc) {
    // clear item_code (name is from item_code)
    doc.item_code = "";

    // first 2 characters based on item_group
    switch(doc.item_group) {
        case "Test A":
            doc.item_code = "TA";
        case "Test B":
            doc.item_code = "TB";
            doc.item_code = "XX";

    // add next 2 characters based on brand
    switch(doc.brand) {
        case "Brand A":
            doc.item_code += "BA";
        case "Brand B":
            doc.item_code += "BB";
            doc.item_code += "BX";

can’t you just setup a 2nd naming series for the 2nd entity? Then both count 001, 002, 003 … independently

  • SINVa-0001, SINVa-0002, SINVa-0003, …
  • sinvB-0001, sinvB-0002, sinvB-0003, …

We have done the custom script. I wanted to know if others have the similar requirement and help to make this standard when multi-entities are selected. at the moment, we have to script it for every document in the system.

thanks for your help.

1 Like

This is required especially in small companies sharing similar product line
Similar customers & purchase Items but billing separately

I have similar requirement . can anyone share the script for naming series by entity ?

frappe.ui.form.on(“Purchase Order”, {
company: = function(doc, cdt, cdn){
// this function is called when the value of company is changed.
if( ‘Company1’){
var cname=“C1”;

else if( == 'Company2''){
	var cname="C2";

var cmsg="Company Name Selected is ";

1 Like

If we setup as described, what if the user amended the document, and change the entity ?
the naming series will be remained as original link series, any comment on how to avoid this ?