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
}
})
});