Hello ,
I am trying in my doctype to call function and do some python code then call back the result
I try every thing but I still have strange problem !!
Here is my code, so when employee feild change the method will run but here it didnt !
employee: function(frm) {
return frappe.call({
method: "erpnext.hr.doctype.end_of_service_award.end_of_service_award.get_it",
args: {
salary: frm.doc.salary,
},
callback: function(r) {
if (r.message) {
alert("done");
}
}
});
},
And here is my python code
@frappe.whitelist()
def get_it(self,salary):
ss = salary
return ss
I wonder what is my problem !
I also try to call the function by using doc: cur_frm.doc,
but it didnt work with me !
Thanks all
JoEz
February 13, 2017, 5:15pm
2
where did u put this code?
In the same doctype’s python file
JoEz
February 13, 2017, 5:19pm
5
please copy and past the path
when I try to make new function and call it it say:
AttributeError: ‘module’ object has no attribute ‘get_it’
here is my code
frappe.ui.form.on(‘End of Service Award’, {
refresh: function(frm) {
employment(frm);
},
});
function employment(frm) {
return frappe.call({
method: “erpnext.hr.doctype.end_of_service_award.end_of_service_award.get_it”,
// args: {
// salary: frm.doc.salary,
// },
callback: function(r) {
if (r.message) {
alert(“done”);
// frm.set_value(‘salary’, r.message);
}
}
});
};
and here is my python code
from future import unicode_literals
import frappe
from frappe.model.document import Document
class EndofServiceAward(Document):
def get_it(self):
return “done”
JoEz
February 13, 2017, 5:25pm
7
what’s the path of the python file?
JoEz
February 13, 2017, 5:35pm
9
OmarJaber:
self
the path seems to be correct, try:
@frappe.whitelist()
def get_it(salary):
ss = salary
return ss
JoEz
February 13, 2017, 5:40pm
11
what’s the error?
Can you past all the py file?
It stop working , js problem
JoEz
February 13, 2017, 5:43pm
13
can you past the py file?
JoEz
February 13, 2017, 5:45pm
15
its indented like this?
class EndofServiceAward(Document):
pass
@frappe.whitelist()
def get_it(salary):
ss = salary
return ss
JoEz
February 13, 2017, 5:50pm
17
can’t find the error, sorry. I think it’s an error on method call, but can’t actually find it … try to move end_of_service_award.py
in the path …
1 Like
Ok, I am trying with it
thanks any way
renga
February 17, 2017, 4:16am
19
Hi,
Check the js function trigger or not when change employee filed’s value,If not trigger error in js side so check and clear [quote=“OmarJaber, post:1, topic:20375”]
end_of_service_award
[/quote]than proceed next step.
1 Like
thanks for helping,
The code is correct, it was browser problem
thanks all