Hi there,
i implemented a button in my doc(doctype 1) calling the quick entry for doctype 2. while the quick entry works i want to stay on my current form and not be redirected to the newly created doc. what is the order for the frappe.new_doc()
to stop the redirect? i cant find it in the documentation and i didnt fully understand the frappe code yet. thanks in advance.
best regards
jh4nni
Any idea on how to achieve the same?
My solution involves creating a dialog, making a frappe.call, and using the callback to refresh the document and hide the dialog. I am open to easier alternatives. Here is my Code for a Client Script :
Code
frappe.ui.form.on('Item', {
refresh(frm) {
document.getElementById('new-manu-btn').addEventListener('click', function() {
// Show the Quick Entry form for Item Manufacturer
let d = new frappe.ui.Dialog({
title: 'Create Item Manufacturer',
fields: [
{
fieldname: 'item_code',
label: 'Item Code',
fieldtype: 'Data',
default: frm.docname,
read_only: 1
},
{
fieldname: 'manufacturer',
label: 'Manufacturer',
fieldtype: 'Link',
options: 'Manufacturer',
reqd: 1
},
{
fieldname: 'manufacturer_part_no',
label: 'Manufacturer Part No',
fieldtype: 'Data'
}
],
primary_action_label: 'Save',
primary_action(values) {
// Insert new Item Manufacturer document
frappe.call({
method: 'frappe.client.insert',
args: {
doc: {
doctype: 'Item Manufacturer',
item_code: values.item_code,
manufacturer: values.manufacturer,
manufacturer_part_no: values.manufacturer_part_no
}
},
callback: function(r) {
if (r.message) {
frappe.msgprint(__('Item Manufacturer created successfully'));
frm.reload_doc(); // Refresh the current document
} else {
frappe.msgprint(__('Failed to create Item Manufacturer'));
}
}
});
d.hide();
}
});
// Show the dialog
d.show();
});
}
});