I want to extend salary slip functionality so I tried to call get_emp_and_leave_details
frappe.call({
"method": "erpnext.erpnext.hr.doctype.salary_slip.salary_slip.SalarySlip.get_emp_and_leave_details",
args: {
docs: frm.doc
} ,
callback: function (data) {
console.log(data);
}
});
but it gives me an error:
The resource you are looking for is not available
I know it is not whitelisted. but is there a workaround to call not whitelist function in the custom app?
vijaywm
February 18, 2018, 4:09am
#2
Since you are building a custom app, can think of making a whitelisted api function and call SalarySlip.get_emp_and_leave_details from there.
In custom app…
@frappe.whitelist()
def get_emp_and_leave_details(dt, dn)
doc = frappe.get_doc(dt, dn)
from erpnext.erpnext.hr.doctype.salary_slip.salary_slip.SalarySlip import get_emp_and_leave_details
doc.get_emp_and_leave_details()
1 Like
$c('runserverobj', { 'method': 'get_emp_and_leave_details', 'docs': doc }, callback);
};
},
function() {
if(frappe.dom.freeze_count) {
frappe.dom.unfreeze();
frm.events.refresh(frm);
}
}
);
};
cur_frm.cscript.get_employee_details = function (doc) {
var callback = function (r) {
if (r.docs[0].employees){
cur_frm.refresh_field('employees');
}
};
return $c('runserverobj', { 'method': 'fill_employee_details', 'docs': doc }, callback);
};
let make_bank_entry = function (frm) {
var doc = frm.doc;
I haven’t tested it. Hope it helps.
@vijaywm Thank you for your reply but is not working, I tried this before and give this error:
from erpnext.erpnext.hr.doctype.salary_slip.salary_slip.SalarySlip import get_emp_and_leave_details
ImportError: No module named erpnext.hr.doctype.salary_slip.salary_slip.SalarySlip
try this
frappe.call({
method:"get_emp_and_leave_details",
doc:frm.doc, // place doc here
args: {
// no need for docs: frm.doc here.
},
callback:function (r) {
console.log(r);
}
});
@revant_one I am sorry for the confusion .
I am trying to call get_emp_and_leave_details from custom js doctype, not from salary_slip.js
vijaywm
February 20, 2018, 10:31am
#7
Thanks @revant_one . That works great. (in a different scenario…not related to hr)
@Mohammed_Redha Did you get it working ? I suppose it can be called from any custom doctype js, within desk.
1 Like
@vijaywm No , it is not working for me
@vijaywm Thank you so much
I tried without import:
@frappe.whitelist()
def get_emp_and_leave_details(self):
doc = frappe.get_doc(self.doctype, self.name)
doc.get_emp_and_leave_details()
and working like a charm
2 Likes