And Sales Invoice for apply it.
frappe.ui.form.on('Sales Invoice', {
refresh: function(frm, cdt, cdn) {
var row = locals[cdt][cdn];
if (cint(frm.doc.docstatus===0) && cur_frm.page.current_view_name!=="pos" && !frm.doc.is_return) {
frm.add_custom_button(__('Sales Order'),
function() {
if (!frm.doc.customer) {
frappe.throw({
title: __("Mandatory"),
message: __("Please Select a Customer")
});
}
erpnext.utils.map_current_doc({
method: "erpnext.selling.doctype.sales_order.sales_order.make_sales_invoice",
source_doctype: "Sales Order",
target: frm,
setters: {
transaction_date: null,
customer: frm.doc.customer,
},
get_query_filters: {
docstatus: 1,
status: ["not in", ["Closed", "On Hold"]],
per_billed: ["<", 99.99],
company: frm.doc.company,
}
});
}, __("Get Items From"));
}
}
});
Thank You!
