I have create 2 new doctypes but i have some issues

hey all ,
i have create 2 doctypes inside education module , one called sections and the other one called student section enrollment , and i have create a doctype as table called registered courses , then i have Put that table inside student section enrollment in this table i have these filed : section as link to sections doctype
and course ( i want to fetched from section doctype ) and registration date (it’s should be the time ‘now’)
and credit hours ( i want to fetched from course doctype ‘i have add this fild’ when i do fetch the course name from section doctype ) , my problem is
i have create a new method :

@frappe.whitelist()
def get_section(section):
	courses = frappe.db.sql('''select course from `tabsections` where name=%s''',
			(section), as_dict=1)
	return courses

and i have but this method inside api file in education module

and i have create a new custom script :

frappe.ui.form.on(‘registered courses’,‘section’, function(frm, cdt, cdn){

    frappe.call({
    "type":"POST",
    "method": "erpnext.education.api.get_section",
    args: {
        section : frm.doc.section
    },
    callback: function (data) {
        frappe.model.set_value(cdt, cdn, "course_name", data.message.course);
       frappe.model.set_value(cdt, cdn, "credit_hours", data.message.credit_hours);



    }

    })

    }) 

but when try to run this custom script , i got this error :

AttributeError: module ‘erpnext.education.api’ has no attribute ‘get_section’

i have do this commands :

bench build
bench migrate

note : i have to sites inside this bench (site.local) and (erp2.site)
and i have create these doctypes in erp2.site

please tell me if you need more explanations

Use this command in your apps folder and try again:

find . -name "*.pyc" -exec rm -f {} \;
1 Like

ok its work i can find the method , now i have another issue , how can i get the input value

i have use this to pass the argument

args: {
section : frm.doc.section
}

my filed name is section and its contain the Name for that section i ahve selected

var selected_row = frm.get_field("TABLE_FIELD").grid.grid_rows_by_docname[cdn];
selected_row.doc.section //this is the value

or

locals[cdt][cdn].section
1 Like

@Nahuel_Nso thank you so much , all solutions is work