Custom script for serial No

Hi

My goal is the following…

When creating purchase receipt, I create a Quality Inspection ( Goods receive )
I have a few lines of custom client coding on “quality INspection” to set the filters on some fields,
that seem to be working well.

I then want to select “Serial No” field and select “Create new serial No”. This then opens a new serial no document that requires me to enter a serial no ( serial no field in Item master is blank, so I have to enter tne serial no )

I would like to auto-complete the “Item-code” field on “Serial No” and I was hoping to achieve it as follows:

Create custom field on “Serial No” called “Quality Inspection”
Create Documetn link from “Quality Inspection” doctype to “Quality Inspection” field on “SerialNo”
This should load the quality inspection document nr in the field “quality inspection” in “Serial No” and allow me to create a custom client script that looks like this…

frappe.ui.form.on('Serial No', {
    // Triggered when the form is loaded
    refresh: function(frm) {
        // Check if the Serial No document is created from Quality Inspection
        if (frm.doc.quality_inspection) {
            frappe.call({
                method: 'frappe.client.get_value',
                args: {
                    doctype: 'Quality Inspection',
                    filters: { name: frm.doc.quality_inspection },
                    fieldname: 'item_code'
                },
                callback: function(r) {
                    if (r.message && r.message.item_code) {
                        // Set the "item_code" field in the Serial No form
                        frm.set_value('item_code', r.message.item_code);
                    }
                }
            });
        }
    }
});

Which I believe should auto-load the item_code on the new Serial No document.

The problem is, the system will not allow me to create a custom field on “Serial No” called “quality_inspection”. The system adds a “custom” i.e. “custom_quality_inspection”
This is sinking my whole idea of how to auto-populate “item_code”

Is there any ay I can force the system to accept a custom field name “quality_inspection” ?
This is on the latest V14
The latest V13 allows me to create my custom field.

Any guidance will be apprecaited.

Hi @willspenc,

Because of the new update in version 14.

Please check the whole post.

Reference:

I hope this helps.

Thank You!

Thank you @NCP for your insight offered to me.

I read the thread and it seem that the new “feature” can be overriden ?

I have made a post on to the thread that you quoted and I am hoping to get some clarity. It seems
one can “override” the Custom field class by writing a custom app. I have done a lot of custom client scripts lately so I am progressing, but I have never written a custom app.

Thank you for your time @NCP