Good Morning Guys
I am a new in Frappe framework and ERP NEXT.
I have a two doctype named Tasks jobs, I want to make a button in jobs doctype to get submitted tasks like in sales order button that get submitted quotations in ERP NEXT, thanks for help and corporate.
Hi @Ahmed_Abdelkarim_Abo,
please use this code for help
//to create custom button
frappe.ui.form.on(“Ferro Pipeline”, {
refresh: function(frm) {
var me = this
if(!frm.doc.islocal) {
cur_frm.add_custom_button((‘Make Ferro Order’), function() {
cur_frm.cscript.make_ferro_order();
});
}
}
Thanks for your quick response, but when I write down the script below the button doesn’t appear.
the script:-
cur_frm.cscript.make_ferro_order =function(){
frappe.model.open_mapped_doc({
method: “kpi.kpi.doctype.ferro_pipeline.ferro_pipeline.make_ferro_order”,
frm: cur_frm
});
}
if (this.frm.doc.docstatus===0) {
cur_frm.add_custom_button(__(‘Tasks’),
function() {
frappe.model.map_current_doc({
method: “external_maintenance.External Maintenance.doctype.Tasks.Taks.jobs”,
source_doctype: “Tasks”,
get_query_filters: {
docstatus: 1,
status: [“!=”, “Closed”],
}
})
}, __(“Get Tasks from”));
}
I tried also the script below:
frappe.ui.form.on(“jobs”, “button_3”, function(frm) {
frappe.model.with_doc(“Tasks”, frm.doc.status, function() {
var po = frappe.model.get_doc(“Tasks”, frm.doc.status);
frm.set_value(“open_ticket_date”, po.open_ticket_date);
});
});
I got the error as shown
hi,
please use this code
frappe.ui.form.on(“Doctype Name”, {
refresh: function(frm) {
var me = this
if(!frm.doc.islocal) {
cur_frm.add_custom_button((‘Button_Name’), function() {
cur_frm.cscript.make_ferro_order(); //Method to click on button
});
}
}
frappe.ui.form.on(“test”, {
refresh: function(frm) {
var me = this
if(!frm.doc.__islocal) {
cur_frm.add_custom_button(_(‘button1’), function() {
//cur_frm.cscript.make_ferro_order()
cur_frm.add_fetch(“test”, “open_ticket_date”, “open_ticket_date”)
});
}
}
I tried this but I found nothing in the screen the button name is button1 and not linked in options, when I remove this code the screen appear again
@Ahmed_Abdelkarim_Abo
refer code from sales_order.js and ‘make_sales_order’ method from quotation.py for that
your code will be like that -
//condition to add custom button
cur_frm.add_custom_button(__('From Tasks'),
function() {
frappe.model.map_current_doc({
method: // path of your py method,
source_doctype: "Tasks",
get_query_filters: {
docstatus: 1,
// add your filters
}
})
});