only show "Create Expense" icon for Alms when document has been saved (not on new documents)

This commit is contained in:
meichthys 2025-11-13 05:02:03 +00:00
parent 7799abd709
commit 1fbfa9268e
2 changed files with 22 additions and 12 deletions

View File

@ -4,20 +4,21 @@
frappe.ui.form.on('Church Alms Request', {
refresh(frm) {
// Add a custom button that creates an Expense from the Alms Request
frm.add_custom_button(__('Create Expense'), function () {
frappe.call({
method: 'church.church_finances.doctype.church_alms_request.church_alms_request.create_expense',
args: {
alms_request_name: frm.doc.name
},
callback: function () {
frm.reload_doc();
}
if (!frm.is_new()) {
frm.add_custom_button(__('Create Expense'), function () {
frappe.call({
method: 'church.church_finances.doctype.church_alms_request.church_alms_request.create_expense',
args: {
alms_request_name: frm.doc.name
},
callback: function () {
frm.reload_doc();
}
});
});
});
}
},
});

View File

@ -5,6 +5,7 @@
"creation": "2025-11-10 22:56:15.677299",
"description": "A request for financial support for a person or family",
"doctype": "DocType",
"documentation": "/app/manual%3A-finances",
"engine": "InnoDB",
"field_order": [
"recipient_type",
@ -66,13 +67,20 @@
"default": "Pending",
"fieldname": "status",
"fieldtype": "Select",
"in_list_view": 1,
"in_preview": 1,
"in_standard_filter": 1,
"label": "Status",
"options": "Pending\nDeclined\nApproved\nDistributed"
},
{
"description": "Required to 'Create Expense'. The fund associated with the selected expense will be reduced by the alms 'Amount'.",
"documentation_url": "/app/manual%3A-finances",
"fieldname": "expense_type",
"fieldtype": "Link",
"in_list_view": 1,
"in_preview": 1,
"in_standard_filter": 1,
"label": "Expense Type",
"options": "Church Expense Type"
}
@ -80,7 +88,7 @@
"grid_page_length": 50,
"index_web_pages_for_search": 1,
"links": [],
"modified": "2025-11-12 22:57:54.155053",
"modified": "2025-11-12 23:35:45.753076",
"modified_by": "Administrator",
"module": "Church Finances",
"name": "Church Alms Request",
@ -128,6 +136,7 @@
}
],
"row_format": "Dynamic",
"show_preview_popup": 1,
"sort_field": "modified",
"sort_order": "DESC",
"states": [