Problem with server script

Hi everyone,

I’m new on Frappe Framework and I install it with the default APP “Frappe”.
In this App, I create my module named “GED” and inside, lots of doctypes.

I’ve a specific doctype with one client script like this who call a server script with frappe.call() but I don’t understand the path I need to fill at the method.

Can you help me please ?

frappe.ui.form.on('Gestion des prets', {
    validate: function(frm) {
        if(frm.doc.status === 'En cours') {
            frappe.call({
                method: 'frappe.client.get_list',
                args: {
                    doctype: 'Gestion des prets',
                    filters: {
                        serial_number: frm.doc.serial_number,
                        status: 'En cours',
                        name: ['!=', frm.docname]
                    },
                    fields: ['name']
                },
                callback: function(response) {
                    if(response.message && response.message.length > 0) {
                        frappe.msgprint(__('Un prêt en cours avec ce numéro de série existe déjà.'));
                        frappe.validated = false;
                    }
                }
            });
        }
    },
    refresh: function(frm) {
        if(frappe.user.has_role('IT - Technique N1')) {
            frm.add_custom_button(__('Terminer le prêt'), function() {
                if(frm.doc.status === 'En cours') {
                    frappe.confirm(
                        __('Êtes-vous sûr de vouloir terminer ce prêt ?'),
                        function() {
                            frappe.call({
                                method: 'frappe.ged_technique.ged_technique.demo.terminate_loan',
                                args: { docname: frm.docname },
                                freeze: true,
                                callback: function(response) {
                                    if(response.message) {
                                        frappe.msgprint(response.message);
                                        frm.reload_doc();
                                    }
                                }
                            });
                        },
                        function() {
                            // Annulation de la confirmation
                        }
                    );
                } else {
                    frappe.msgprint(__('Le prêt doit être en cours pour être terminé.'));
                }
            }).toggleClass('btn-primary', frm.doc.status === 'En cours');
        }
    }
})

Server script :

@frappe.whitelist()
def terminate_loan(docname):
doc = frappe.get_doc(‘Gestion des prets’, docname)

if doc.status == 'En cours':
    doc.status = 'Terminé'
    doc.save(ignore_permissions=True)

    return 'Le prêt a été terminé avec succès.'
else:
    return 'Le prêt doit être en cours pour être terminé.'

Hi @FC-Supp_Info,

I think, the path is wrong.

Please apply it.

method: 'frappe.ged_technique.doctype.gestion_des_prets.gestion_des_prets.terminate_loan',

frappe is the app,
ged_technique is the module
gestion_des_prets is the doctype and basically, it will be stored in the doctype folder.

gestion_des_prets.js / gestion_des_prets.py is file which store in gestion_des_prets folder.

terminate_loan is the method you are calling in gestion_des_prets.py file.

i hope this helps.

Thank You!