Try ERPNext Buy Support Partners Foundation

Custom Script to Populate Table with Months (Similar to Monthly Distribution's get_months)

Hi everyone, I am working on a doctype (named Sales Planning) that I have created. I wanted to auto-populate a table with months similarly to Month Distribution doctype’s get_months

Can anyone guide me? Below is my Custom Script.

frappe.ui.form.on('Sales Planning', {
    before_load: function(frm) {    
        if (!frm.is_new()) {
            if (frm.doc.is_root==1) {
                frm.set_read_only();
                frm.disable_save();
            }
        }
    },
    refresh: function(frm) {        
        if (!frm.is_new()) {
            if (frm.doc.is_root==1) {
                frm.set_read_only();
                frm.set_intro(__('This is a root Sales Planning and cannot be edited.'));
            }
        } else {
            frm.set_intro(null);
        }
    },
    timeline_refresh: function(frm) { 
        if (!frm.is_new()) {
            if (frm.doc.is_root==1) {
                frm.set_read_only();
            }
        }
    }
});

cur_frm.fields_dict['parent_sales_planning'].get_query = function(doc, cdt, cdn) {
	return{
		filters: [
			['Sales Planning', 'is_group', '=', 1],
			['Sales Planning', 'sales_planning_title', '!=', doc.sales_planning_title]
		]
	};
};
frappe.ui.form.on('Previous FY Sales Target', {
    onload: function(frm) {
        if(frm.doc.__islocal && frm.doc.previous_fiscal_year_sales_target) {
            frm.set_value('mth', ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']);
        }
    }
});

.
.
’Sales Planning’ doctype

.
’Previous Fiscal Year Sales Target’ child table doctype:

Version: v12.2.0
Thank you in advance!

Would really appreciate if there’s anyone that can help out.