Nameerror: name 'frappe' is not defined in Workflow - in V12.5.2

Dear Community,

I can not use frappe in the condition in WorkFlow
I face this error "nameerror: name 'frappe' is not defined"
I think it changes to another keyword,

Please, anyone, provide me with the new.

Thank you in advance.

Dear @clarkej ,

First of all, I’am sorry about the mention, I know that this is a community.
but this issue is a critical.

Thank you.

Please share the full traceback here.

To list the problem Workflow condition expression, with notes on relevant changes you have made and exactly when the issue started, will help.

If your instance is hosted on erpnext.com best to contact support@erpnext.com I think.

Otherwise folks here may be able to spot the problem.

Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/save.py”, line 22, in savedocs
doc.save()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 273, in save
return self._save(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 296, in _save
self.insert()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 260, in insert
self.run_post_save_methods()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 926, in run_post_save_methods
self.run_method(“on_update”)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 794, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 1065, in composer
return composed(self, method, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 1050, in runner
add_to_return_value(self, f(self, method, *args, **kwargs))
File “/home/frappe/frappe-bench/apps/frappe/frappe/workflow/doctype/workflow_action/workflow_action.py”, line 49, in process_workflow_actions
next_possible_transitions = get_next_possible_transitions(workflow, get_doc_workflow_state(doc), doc)
File “/home/frappe/frappe-bench/apps/frappe/frappe/workflow/doctype/workflow_action/workflow_action.py”, line 158, in get_next_possible_transitions
if transition.condition and not frappe.safe_eval(transition.condition, None, {‘doc’: doc.as_dict()}):
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 1547, in safe_eval
return eval(code, eval_globals, eval_locals)
File “”, line 1, in
NameError: name ‘frappe’ is not defined

Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/app.py”, line 60, in application
response = frappe.api.handle()
File “/home/frappe/frappe-bench/apps/frappe/frappe/api.py”, line 55, in handle
return frappe.handler.handle()
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 22, in handle
data = execute_cmd(cmd)
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 61, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 1051, in call
return fn(*args, **newargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/save.py”, line 22, in savedocs
doc.save()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 273, in save
return self._save(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 296, in _save
self.insert()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 260, in insert
self.run_post_save_methods()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 926, in run_post_save_methods
self.run_method(“on_update”)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 794, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 1065, in composer
return composed(self, method, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 1050, in runner
add_to_return_value(self, f(self, method, *args, **kwargs))
File “/home/frappe/frappe-bench/apps/frappe/frappe/workflow/doctype/workflow_action/workflow_action.py”, line 49, in process_workflow_actions
next_possible_transitions = get_next_possible_transitions(workflow, get_doc_workflow_state(doc), doc)
File “/home/frappe/frappe-bench/apps/frappe/frappe/workflow/doctype/workflow_action/workflow_action.py”, line 158, in get_next_possible_transitions
if transition.condition and not frappe.safe_eval(transition.condition, None, {‘doc’: doc.as_dict()}):
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 1547, in safe_eval
return eval(code, eval_globals, eval_locals)
File “”, line 1, in
NameError: name ‘frappe’ is not defined

I have a workflow for leave application - and I have a condition for one Transitions record of workflow,
when I make a save for new leave application,
this error happened "nameerror: name 'frappe' is not defined"
but when I remove the condition, everything goes OK.
the condition is frappe.session.user==user.owner
All my workflow have conditions | I disable the workflows and the documents work fine.
The issue started after the update to 12.5.2

Same Issue with me

It has been solved, but the reason is not the “frappe.session.user” in the condition.
I will share the solution when it will be discoverd

How did you resolve this issue?

Same Issue with me

Sorry, it still happens.

Sorry, it still happens.

You perhaps need to reimplement a broken Workflow Action

@alkuhlani Thanks for reporting this issue.

This PR should fix the issue.

@surajshetty you are almost welcome.

@clarkej thank you for your great effort

1 Like