i am facing issue in my erpnext :
whenever some bug in code happened i do not get the full description for it >
i have another erpnext machine and it works perfectly :
this is the code :
Fetch the current user document (make sure it’s within the correct scope)
user_doc = frappe.get_doc(‘User’, frappe.session.user)
Ensure roles are available
if user_doc and hasattr(user_doc, ‘roles’):
# Check if the user has any of the specified roles
if any(role.role in [“System Manager”, “DPharma Auditor”] for role in user_doc.roles):
conditions = “”
else:
conditions = “owner = '” + frappe.session.user + “'”
else:
conditions = “owner = '” + frappe.session.user + “'”
in machine 2 which is works fine :
desk.bundle.O55XBYYI.js:sourcemap:453 Traceback (most recent call last):
File “apps/frappe/frappe/app.py”, line 110, in application
response = frappe.api.handle(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File “apps/frappe/frappe/api/init.py”, line 49, in handle
data = endpoint(**arguments)
^^^^^^^^^^^^^^^^^^^^^
File “apps/frappe/frappe/api/v1.py”, line 36, in handle_rpc_call
return frappe.handler.handle()
^^^^^^^^^^^^^^^^^^^^^^^
File “apps/frappe/frappe/handler.py”, line 49, in handle
data = execute_cmd(cmd)
^^^^^^^^^^^^^^^^
File “apps/frappe/frappe/handler.py”, line 85, in execute_cmd
return frappe.call(method, **frappe.form_dict)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “apps/frappe/frappe/init.py”, line 1761, in call
return fn(*args, **newargs)
^^^^^^^^^^^^^^^^^^^^
File “apps/frappe/frappe/utils/typing_validations.py”, line 31, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File “apps/frappe/frappe/init.py”, line 921, in wrapper_fn
retval = fn(*args, **get_newargs(fn, kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “apps/frappe/frappe/desk/reportview.py”, line 32, in get
data = compress(execute(**args), args=args)
^^^^^^^^^^^^^^^
File “apps/frappe/frappe/desk/reportview.py”, line 78, in execute
return DatabaseQuery(doctype).execute(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “apps/frappe/frappe/model/db_query.py”, line 191, in execute
result = self.build_and_run()
^^^^^^^^^^^^^^^^^^^^
File “apps/frappe/frappe/model/db_query.py”, line 206, in build_and_run
args = self.prepare_args()
^^^^^^^^^^^^^^^^^^^
File “apps/frappe/frappe/model/db_query.py”, line 246, in prepare_args
self.build_conditions()
File “apps/frappe/frappe/model/db_query.py”, line 585, in build_conditions
match_conditions = self.build_match_conditions()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “apps/frappe/frappe/model/db_query.py”, line 950, in build_match_conditions
doctype_conditions = self.get_permission_query_conditions()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “apps/frappe/frappe/model/db_query.py”, line 1039, in get_permission_query_conditions
if condition := script.get_permission_query_conditions(self.user):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “apps/frappe/frappe/core/doctype/server_script/server_script.py”, line 197, in get_permission_query_conditions
safe_exec(self.script, None, locals, script_filename=self.name)
File “apps/frappe/frappe/utils/safe_exec.py”, line 100, in safe_exec
exec(
File “: sd”, line 5, in
NameError: name ‘hasattr’ is not defined
as you can see it gives the error and trace it .
but in machine one :
only show me this :
frame_ant.js:1
POST http://10.5.1.202/api/method/frappe.desk.reportview.get 500 (INTERNAL SERVER ERROR)
why ?