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.

Cecilia

@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";
            break;
        case "Test B":
            doc.item_code = "TB";
            break;
        default:
            doc.item_code = "XX";
    }

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

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: cur_frm.cscript.company = function(doc, cdt, cdn){
//function(frm){
// this function is called when the value of company is changed.
if(cur_frm.doc.company=== ‘Company1’){
var cname=“C1”;
cur_frm.set_value(“naming_series”,“PO/C1/”);

}
else if(cur_frm.doc.company == 'Company2''){
	var cname="C2";
	cur_frm.set_value("naming_series","PO/C2/");
}

var cmsg="Company Name Selected is ";
print_msg=cmsg;
print_msg+=cname;
msgprint(print_msg);
}
});

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 ?