ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

Problem when trying to redirect to a new Stock Entry

customization
frappe

#1

I’m having problems with a custom DocType. This custom DocType is similar to a Production Order. When I introduce a material to manufacture, it must redirect me to a new stock entry. The error I have occurs during the Ajax call, when the function frappe.model.sync is called at this point:

...
frappe.call({
    method: 'cleceim.wo.doctype.large_format.large_format.make_stock_entry',
    args: {
        production_order_id: frm.doc.name,
        purpose: purpose,
        qty: (data.qty ? data.qty : 0)
    },
    callback: function (r) {
        var doclist = frappe.model.sync(r.message);
        frappe.set_route('Form', doclist[0].doctype, doclist[0].name);
    }
});
...

The method mentioned above works similarly to the make_stock_entry function in Production Order. The variable purpose is given as an argument to the parent function and the variable qty is given through frappe.prompt.

The Web console returns the error:

TypeError: Cannot read property 'docs' of undefined

If I run console.log(r.message) in callback function the message is totally empty, although I don’t seems errors and the status of the response is 200.

Is it possible that the problem is the return value of the method?