Stop leave approver to approve his own leave

i am writing script to stop leave approver to approve his own leave but its not working

i gone through previous query which is availabe in forum but its changing normal functionality of app

here i am taking empID according to empID i am fechting comapny_email of applied leave employee if company_email == session user then its leave approver so based on this i want to stop approving own leave

frappe.ui.form.on(‘Leave Application’, {
refresh: function(frm) {
if (frm.doc.custom_nstarx_empid) {
// Fetch company_email from the Employee doctype using custom_nstarx_empid
frappe.db.get_value(‘Employee’, frm.doc.custom_nstarx_empid, ‘company_email’, (r) => {
if (r && r.company_email === frappe.session.user) {
frm.disable_save();
frappe.msgprint(__(‘Leave approver not allow to submit own leave.’));
}
});
}
}
});

Try this on_submit,
frappe.ui.form.on(‘Leave Application’, {
on_submit: function(frm) {
if (frm.doc.custom_nstarx_empid) {
// Fetch company_email from the Employee doctype using custom_nstarx_empid
frappe.db.get_value(‘Employee’, frm.doc.custom_nstarx_empid, ‘company_email’, (r) => {
if (r && r.company_email === frappe.session.user) {
frm.disable_save();
frappe.throw(__(‘Leave approver not allow to submit own leave.’));
}
});
}
}
});
[/quote]

tried but not working

Try this,
usr = frappe.session.user
if usr == doc.leave_approver:
frappe.throw(“Leave Approver Cannot Apply his Own Leave”)

This Python script worked successfully