Hi there,
I have created a custom doctype Disciplinary Action.
In that i have an option of Termination as soon as the Authorized person clicks on the termination button the employee status must change to Left from Active
How can i implement this?
Hi ! I think you have to apply workflow
https://frappe.github.io/erpnext/user/manual/en/setting-up/workflows
Hi there can you please ellaborate it?
Hello the link that I gave you is fully documented, please refer there. thanks!
Disciplinary Action is one Doctype and Employee is another Doctype how can i change the status of employee by clicking on a button on Disciplinary Action Doctype?
By workflow we can change the state on employee but it cant be based on Disciplinary action.
@Ujjawal
write a script on button trigger and using frappe.call
change status of employee using python code
frappe.db.set_value("Doctype", "docname", "field", "value")
e.g
frappe.db.set_value("Employee", "name_of_doc", "status", "Left")
I am getting an error…
My JS Script:
frappe.ui.form.on(‘Disciplinary Action’, {
reject: function(frm) {
if (!frm.doc.__islocal) {
alert(“Are you sure you want to terminate the employee?”);
frappe.call({
method: "erpnext.hr.doctype.disciplinary_action.disciplinary_action.terminate",
args:{
employee:frm.doc.employee
},
callback: function(r){
if (r.message) {
frappe.msgprint("Employee has been terminated.");
}
else {
frappe.throw("Unable to Terminate.");
}
}
});
}
else {
frappe.throw(("Save the Document first."));
}
}
});
My Python Script:
class DisciplinaryAction(Document):
@frappe.whitelist()
def terminate(employee):
frappe.db.set_value("Employee", employee, "status", "Left")
The error is:
The method path is correct sir.
It is already present.
under which module Disciplinary Action
is present ?
have you return anything from py method ?
Disciplinary module is under HR Module.
No nothing has been returned.
Any Update on this?
make sure your python method is written under class DisciplinaryAction(Document)
.
I think you wrote it outside. Please check.
No Idea why this happening.
One more thing return something from a py side. Because you capturing response
@Ujjawal Hi
In Python file you have written whitelisted method inside the class.
Please write it outside the class
It raises an error expected indented block if whitelist is done outside the class.
write pass inside class