feat: remove button on import of an order

This commit is contained in:
Mangesh-Khairnar 2019-05-11 20:04:03 +05:30
parent 644e181729
commit cd4289e10e
3 changed files with 50 additions and 35 deletions

View File

@ -16,9 +16,12 @@ frappe.ui.form.on('Payment Order', {
frm.add_custom_button(__('Payment Request'), function() {
frm.trigger("get_from_payment_request");
}, __("Get from"));
frm.add_custom_button(__('Payment Entry'), function() {
frm.trigger("get_from_payment_entry");
}, __("Get from"));
frm.trigger('remove_button');
}
// payment Entry
@ -30,11 +33,27 @@ frappe.ui.form.on('Payment Order', {
}
},
get_from_payment_entry: function(frm) {
remove_row_if_empty: function(frm) {
// remove if first row is empty
if (!frm.doc.references[0].reference_name) {
if (frm.doc.references.length > 0 && !frm.doc.references[0].reference_name) {
frm.doc.references = [];
}
},
remove_button: function(frm) {
let label = ["Payment Request", "Payment Entry"]
if (frm.doc.references.length > 0 && frm.doc.payment_order_type) {
label = label.reduce(x => {
x!= frm.doc.payment_order_type;
return x;
});
frm.remove_custom_button(label, "Get from");
}
},
get_from_payment_entry: function(frm) {
frm.trigger("remove_row_if_empty");
erpnext.utils.map_current_doc({
method: "erpnext.accounts.doctype.payment_entry.payment_entry.make_payment_order",
source_doctype: "Payment Entry",
@ -52,10 +71,7 @@ frappe.ui.form.on('Payment Order', {
},
get_from_payment_request: function(frm) {
// remove if first row is empty
if (!frm.doc.references[0].reference_name) {
frm.doc.references = [];
}
frm.trigger("remove_row_if_empty")
erpnext.utils.map_current_doc({
method: "erpnext.accounts.doctype.payment_request.payment_request.make_payment_order",
source_doctype: "Payment Request",
@ -116,5 +132,4 @@ frappe.ui.form.on('Payment Order', {
dialog.show();
},
});

View File

@ -79,6 +79,7 @@
"fieldtype": "Select",
"label": "Payment Order Type",
"options": "\nPayment Request\nPayment Entry",
"read_only": 1,
"reqd": 1
},
{
@ -98,7 +99,7 @@
}
],
"is_submittable": 1,
"modified": "2019-05-08 16:00:09.027739",
"modified": "2019-05-09 13:57:12.974008",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Payment Order",

View File

@ -1,8 +1,7 @@
frappe.ui.form.on('Payment Order', {
refresh: function(frm) {
if (frm.doc.docstatus==1 && frm.doc.payment_order_type==='Payment Entry') {
frm.add_custom_button(__('Generate Text File'),
function() {
frm.add_custom_button(__('Generate Text File'), function() {
frm.trigger("generate_text_and_download_file");
});
}