I Need Your Support , what is the error with this code @ Stock entry

want to make validation on Series (Select list) according to the Company (about 8 Companies in the list) :

frappe.ui.form.on(“Company”, “Series”, function(frm) {
if(frm.doc.Company == “S Lab”)
{
set_field_options(“Series”, [“SLB-STE-.YYYY.-”])
}
elseif(frm.doc.Company == “S Reclamation”)
{
set_field_options(“Series”, [“SRC-STE-.YYYY.-”])
}
elseif(frm.doc.Company == “zan”)
{
set_field_options(“Series”, [“MZN-STE-.YYYY.-”])
}
});

Can you do this in python def autoname?

What I want is to validate the Selection in Series Field , When Selecting a certain Company, at Stock entry Doctype .

May be this thread will help

1 Like

Thanks you
it is Solved when making Series field - Read Only
and Select the company in Default Session.

cur_frm.cscript.onload_post_render = function(doc,cdt,cdn){
if(cur_frm.doc.company == “SLb”){
cur_frm.set_value(“naming_series”,“SLB-STE-.YYYY.-”);
}
if(cur_frm.doc.company == “SRC”){
cur_frm.set_value(“naming_series”,“SRC-STE-.YYYY.-”);
}
if(cur_frm.doc.company == “Mzn”){
cur_frm.set_value(“naming_series”,“MZN-STE-.YYYY.-”);
}
if(cur_frm.doc.company == “Lts”){
cur_frm.set_value(“naming_series”,“LTS-STE-.YYYY.-”);
}
};

and the following also Working;
frappe.ui.form.on(‘Stock Entry’, {
refresh(frm) {
if(cur_frm.doc.company == “SLb”)
cur_frm.set_value(“naming_series”,“SLB-STE-.YYYY.-”);
if(cur_frm.doc.company == “SRC”)
cur_frm.set_value(“naming_series”,“SRC-STE-.YYYY.-”);
if(cur_frm.doc.company == “MZN”)
cur_frm.set_value(“naming_series”,“MZN-STE-.YYYY.-”);
if(cur_frm.doc.company == “LTS”)
cur_frm.set_value(“naming_series”,“LTS-STE-.YYYY.-”);
}
});

Thanks you again