Editing Item Varient controller - Help Needed

I want to edit make_variant_item_code def in itemvarient.py file. Actually erpnext is assigning itemcode and itemname as same in the below line
variant.item_code = “{0}-{1}”.format(template_item_code, “-”.join(abbreviations))
variant.item_name = “{0}-{1}”.format(template_item_name, “-”.join(abbreviations))
But I want item_code same as above and Item_name instead of abbr i want to put varient name through custom app. Anybody can guide me please…

1 Like

Any help please suggest…

If you use a class override hook, you can edit the controller however you’d like:


@peterg Thanks for the link. I checked the docs. When i add the code in refresh event as below
frappe.ui.form.on(“Item”, {
refresh: function(frm) {
my_custom_code: function(frm){
frappe.msgprint(“test from js”)
it is working. But actually I want the code to run when i click on Create Variants button… Since two days i am stuck here… kindly help…

Hi there,

I don’t think what you’re trying to do will be possible with client side JavaScript. If you’re trying to override the Python, you’ll need to do it with Python.

I have the same request, I don’t want to use attributes abbreviation when generating variant.item_name, but attributes value.
@ErpnextRaja Did you get it to work?

I see that the documentation suggests that “> It is recommended that you extend the standard class of the doctype, otherwise > you will have to implement all of the core functionality.”