feat: remove button on import of an order
This commit is contained in:
parent
644e181729
commit
cd4289e10e
@ -16,9 +16,12 @@ frappe.ui.form.on('Payment Order', {
|
|||||||
frm.add_custom_button(__('Payment Request'), function() {
|
frm.add_custom_button(__('Payment Request'), function() {
|
||||||
frm.trigger("get_from_payment_request");
|
frm.trigger("get_from_payment_request");
|
||||||
}, __("Get from"));
|
}, __("Get from"));
|
||||||
|
|
||||||
frm.add_custom_button(__('Payment Entry'), function() {
|
frm.add_custom_button(__('Payment Entry'), function() {
|
||||||
frm.trigger("get_from_payment_entry");
|
frm.trigger("get_from_payment_entry");
|
||||||
}, __("Get from"));
|
}, __("Get from"));
|
||||||
|
|
||||||
|
frm.trigger('remove_button');
|
||||||
}
|
}
|
||||||
|
|
||||||
// payment Entry
|
// 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
|
// 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 = [];
|
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({
|
erpnext.utils.map_current_doc({
|
||||||
method: "erpnext.accounts.doctype.payment_entry.payment_entry.make_payment_order",
|
method: "erpnext.accounts.doctype.payment_entry.payment_entry.make_payment_order",
|
||||||
source_doctype: "Payment Entry",
|
source_doctype: "Payment Entry",
|
||||||
@ -52,10 +71,7 @@ frappe.ui.form.on('Payment Order', {
|
|||||||
},
|
},
|
||||||
|
|
||||||
get_from_payment_request: function(frm) {
|
get_from_payment_request: function(frm) {
|
||||||
// remove if first row is empty
|
frm.trigger("remove_row_if_empty")
|
||||||
if (!frm.doc.references[0].reference_name) {
|
|
||||||
frm.doc.references = [];
|
|
||||||
}
|
|
||||||
erpnext.utils.map_current_doc({
|
erpnext.utils.map_current_doc({
|
||||||
method: "erpnext.accounts.doctype.payment_request.payment_request.make_payment_order",
|
method: "erpnext.accounts.doctype.payment_request.payment_request.make_payment_order",
|
||||||
source_doctype: "Payment Request",
|
source_doctype: "Payment Request",
|
||||||
@ -116,5 +132,4 @@ frappe.ui.form.on('Payment Order', {
|
|||||||
|
|
||||||
dialog.show();
|
dialog.show();
|
||||||
},
|
},
|
||||||
|
|
||||||
});
|
});
|
@ -79,6 +79,7 @@
|
|||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"label": "Payment Order Type",
|
"label": "Payment Order Type",
|
||||||
"options": "\nPayment Request\nPayment Entry",
|
"options": "\nPayment Request\nPayment Entry",
|
||||||
|
"read_only": 1,
|
||||||
"reqd": 1
|
"reqd": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -98,7 +99,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"modified": "2019-05-08 16:00:09.027739",
|
"modified": "2019-05-09 13:57:12.974008",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Payment Order",
|
"name": "Payment Order",
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
frappe.ui.form.on('Payment Order', {
|
frappe.ui.form.on('Payment Order', {
|
||||||
refresh: function(frm) {
|
refresh: function(frm) {
|
||||||
if (frm.doc.docstatus==1 && frm.doc.payment_order_type==='Payment Entry') {
|
if (frm.doc.docstatus==1 && frm.doc.payment_order_type==='Payment Entry') {
|
||||||
frm.add_custom_button(__('Generate Text File'),
|
frm.add_custom_button(__('Generate Text File'), function() {
|
||||||
function() {
|
|
||||||
frm.trigger("generate_text_and_download_file");
|
frm.trigger("generate_text_and_download_file");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user