Fetch mandatory reqd from server side (#13924)
This commit is contained in:
parent
f4feedace4
commit
eec0209e3c
@ -150,6 +150,19 @@ frappe.ui.form.on("Expense Claim", {
|
||||
},
|
||||
|
||||
onload: function(frm) {
|
||||
if (frm.doc.docstatus == 0) {
|
||||
return frappe.call({
|
||||
method: "erpnext.hr.doctype.leave_application.leave_application.get_mandatory_approval",
|
||||
args: {
|
||||
doctype: frm.doc.doctype,
|
||||
},
|
||||
callback: function(r) {
|
||||
if (!r.exc && r.message) {
|
||||
frm.toggle_reqd("expense_approver", true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
frm.set_query("expense_approver", function() {
|
||||
return {
|
||||
query: "erpnext.hr.doctype.department_approver.department_approver.get_approvers",
|
||||
@ -181,11 +194,6 @@ frappe.ui.form.on("Expense Claim", {
|
||||
frm.add_custom_button(__('Payment'),
|
||||
function() { frm.events.make_payment_entry(frm); }, __("Make"));
|
||||
}
|
||||
frappe.db.get_value('HR Settings', {name: 'HR Settings'}, 'expense_approver_mandatory_in_expense_claim', (r) => {
|
||||
if (frm.doc.docstatus < 1 && (r.expense_approver_mandatory_in_expense_claim == 1)) {
|
||||
frm.toggle_reqd("expense_approver", true);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
make_payment_entry: function(frm) {
|
||||
|
@ -9,7 +9,19 @@ frappe.ui.form.on("Leave Application", {
|
||||
if (!frm.doc.posting_date) {
|
||||
frm.set_value("posting_date", frappe.datetime.get_today());
|
||||
}
|
||||
|
||||
if (frm.doc.docstatus == 0) {
|
||||
return frappe.call({
|
||||
method: "erpnext.hr.doctype.leave_application.leave_application.get_mandatory_approval",
|
||||
args: {
|
||||
doctype: frm.doc.doctype,
|
||||
},
|
||||
callback: function(r) {
|
||||
if (!r.exc && r.message) {
|
||||
frm.toggle_reqd("leave_approver", true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
frm.set_query("leave_approver", function() {
|
||||
return {
|
||||
query: "erpnext.hr.doctype.department_approver.department_approver.get_approvers",
|
||||
@ -35,11 +47,6 @@ frappe.ui.form.on("Leave Application", {
|
||||
if(frm.doc.__islocal && !in_list(frappe.user_roles, "Employee")) {
|
||||
frm.set_intro(__("Fill the form and save it"));
|
||||
}
|
||||
frappe.db.get_value('HR Settings', {name: 'HR Settings'}, 'leave_approver_mandatory_in_leave_application', (r) => {
|
||||
if (frm.doc.docstatus < 1 && (r.leave_approver_mandatory_in_leave_application == 1)) {
|
||||
frm.toggle_reqd("leave_approver", true);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
employee: function(frm) {
|
||||
|
@ -461,3 +461,16 @@ def add_holidays(events, start, end, employee, company):
|
||||
"title": _("Holiday") + ": " + cstr(holiday.description),
|
||||
"name": holiday.name
|
||||
})
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_mandatory_approval(doctype):
|
||||
mandatory = ""
|
||||
if doctype == "Leave Application":
|
||||
mandatory = frappe.db.get_single_value('HR Settings',
|
||||
'leave_approver_mandatory_in_leave_application')
|
||||
else:
|
||||
mandatory = frappe.db.get_single_value('HR Settings',
|
||||
'expense_approver_mandatory_in_expense_claim')
|
||||
|
||||
return mandatory
|
||||
|
Loading…
x
Reference in New Issue
Block a user