hello .
i have custom_app named diamondpharma.
file api.py is created inside :
def test(doc=None, method=None):
frappe.logger().info("Issue { successfully raised_by {}".format(doc.name,doc.raised_by))
frappe.msgprint("Issue {} successfully raised by {}".format(doc.name, doc.raised_by))
in hooks.py :
doc_events = {
"Issue": {
"validate": "diamondpharma.diamondpharma.api.test"
},
}
I intentionally removed }
from frappe.logger().info(
.
An error is supposed to appear.
I see it when I change the value of a certain field in the Issue doctype.
The error does not appear when I press F12.
erpnext@erp:~/frappe-bench/sites/kelioa/logs$ bench execute diamondpharma.diamondpharma.api.test --kwargs "{'doc': {'name': 'ISS-2025-00067'}, 'method': 'validate'}"
Traceback (most recent call last):
File "/home/erpnext/frappe-bench/apps/frappe/frappe/commands/utils.py", line 269, in execute
ret = frappe.get_attr(method)(*args, **kwargs)
File "/home/erpnext/frappe-bench/apps/diamondpharma/diamondpharma/diamondpharma/api.py", line 222, in test
frappe.logger().info("Issue { successfully raised_by {}".format(doc.name,doc.raised_by))
ValueError: unexpected '{' in field name
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/home/erpnext/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 114, in <module>
main()
File "/home/erpnext/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 20, in main
click.Group(commands=commands)(prog_name="bench")
File "/home/erpnext/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1161, in __call__
return self.main(*args, **kwargs)
File "/home/erpnext/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1082, in main
rv = self.invoke(ctx)
File "/home/erpnext/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1697, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/erpnext/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1697, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/erpnext/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1443, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/erpnext/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 788, in invoke
return __callback(*args, **kwargs)
File "/home/erpnext/frappe-bench/env/lib/python3.10/site-packages/click/decorators.py", line 33, in new_func
return f(get_current_context(), *args, **kwargs)
File "/home/erpnext/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 29, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File "/home/erpnext/frappe-bench/apps/frappe/frappe/commands/utils.py", line 272, in execute
ret = eval(method + "(*args, **kwargs)", globals(), locals()) # nosemgrep
File "<string>", line 1, in <module>
NameError: name 'diamondpharma' is not defined
Note :
this is from executing the function :
bench execute diamondpharma.diamondpharma.api.test --kwargs “{‘doc’: {‘name’: ‘ISS-2025-00067’}, ‘method’: ‘validate’}”
instead of the error comes according to this method , only this error :
Failed to load resource: the server responded with a status of 500 (INTERNAL SERVER ERROR)
appeared .
why the explanation not showed up ?
please help .
for info :
erpnext@erp:~/frappe-bench/sites/kelioa/logs$ bench list-apps
frappe 15.54.1 version-15
erpnext 15.50.0 version-15
chat 0.0.1 main
diamondpharma 0.0.4 master
scienceoffice 0.0.1 master
hrms 15.39.0 version-15
payments 0.0.1 develop
healthcare 15.0.3 version-15
as you can see diamondpharma is installed .
can any one help me please (any missing configuration) ?
second problem :
frappe.logger().info("Issue {} successfully raised_by {}".format(doc.name,doc.raised_by))
where should the value of this function appeared and show up ?