Skip to content
🤔prompts chat🧠
🔍
question:# App Versions ``` { "chat": "0.0.1", "erpnext": "14.27.12", "frappe": "14.40.3", "posawesome": "6.0.3" } ``` # Route ``` query-report/Item Price List ``` # Traceback ``` Traceback (most recent call last): File "apps/frappe/frappe/app.py", line 94, in application response = frappe.api.handle() File "apps/frappe/frappe/api.py", line 54, in handle return frappe.handler.handle() File "apps/frappe/frappe/handler.py", line 47, 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 1610, in call return fn(*args, **newargs) File "apps/frappe/frappe/__init__.py", line 792, in wrapper_fn retval = fn(*args, **get_newargs(fn, kwargs)) File "apps/frappe/frappe/desk/query_report.py", line 232, in run result = generate_report_result(report, filters, user, custom_columns, is_tree, parent_field) File "apps/frappe/frappe/__init__.py", line 792, in wrapper_fn retval = fn(*args, **get_newargs(fn, kwargs)) File "apps/frappe/frappe/desk/query_report.py", line 90, in generate_report_result res = get_report_result(report, filters) or [] File "apps/frappe/frappe/desk/query_report.py", line 71, in get_report_result res = report.execute_script_report(filters) File "apps/frappe/frappe/core/doctype/report/report.py", line 133, in execute_script_report res = self.execute_script(filters) File "apps/frappe/frappe/core/doctype/report/report.py", line 153, in execute_script safe_exec(self.report_script, None, loc) File "apps/frappe/frappe/utils/safe_exec.py", line 72, in safe_exec exec(compile_restricted(script), exec_globals, _locals) # pylint: disable=exec-used File "env/lib/python3.10/site-packages/RestrictedPython/compile.py", line 211, in compile_restricted raise SyntaxError(result.errors) SyntaxError: ("Line 1: SyntaxError: invalid character '“' (U+201C) at statement: 'result = frappe.db.get_all(“Item Price”, fields=[“*”], filters={“item_code”: “item_code”, “price_list”: “price_list”})'",) ``` # Request Data ``` { "type": "GET", "args": { "report_name": "Item Price List", "filters": "{}", "are_default_filters": true }, "headers": {}, "error_handlers": {}, "url": "/api/method/frappe.desk.query_report.run" } ``` # Response Data ``` { "exception": "SyntaxError: ("Line 1: SyntaxError: invalid character '“' (U+201C) at statement: 'result = frappe.db.get_all(“Item Price”, fields=[“*”], filters={“item_code”: “item_code”, “price_list”: “price_list”})'",)" } ```

answer:The traceback and response data indicate that the issue is related to the presence of invalid characters, specifically the double curly quotation marks (`“` and `”`), in the code snippet you provided. These characters are not valid in Python syntax. To fix the issue, replace the invalid quotation marks with regular double quotation marks (`"`). Here's the corrected code: ```python result = frappe.db.get_all("Item Price", fields=["*"], filters={"item_code": "item_code", "price_list": "price_list"}) ``` After replacing the invalid characters, save your script and try running the script report again. The issue should be resolved, and the script should execute without any syntax errors.

question:# App Versions ``` { "chat": "0.0.1", "erpnext": "14.27.12", "frappe": "14.40.3", "posawesome": "6.0.3" } ``` # Route ``` query-report/Item Price List ``` # Traceback ``` Traceback (most recent call last): File "apps/frappe/frappe/app.py", line 94, in application response = frappe.api.handle() File "apps/frappe/frappe/api.py", line 54, in handle return frappe.handler.handle() File "apps/frappe/frappe/handler.py", line 47, 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 1610, in call return fn(*args, **newargs) File "apps/frappe/frappe/__init__.py", line 792, in wrapper_fn retval = fn(*args, **get_newargs(fn, kwargs)) File "apps/frappe/frappe/desk/query_report.py", line 232, in run result = generate_report_result(report, filters, user, custom_columns, is_tree, parent_field) File "apps/frappe/frappe/__init__.py", line 792, in wrapper_fn retval = fn(*args, **get_newargs(fn, kwargs)) File "apps/frappe/frappe/desk/query_report.py", line 90, in generate_report_result res = get_report_result(report, filters) or [] File "apps/frappe/frappe/desk/query_report.py", line 71, in get_report_result res = report.execute_script_report(filters) File "apps/frappe/frappe/core/doctype/report/report.py", line 133, in execute_script_report res = self.execute_script(filters) File "apps/frappe/frappe/core/doctype/report/report.py", line 153, in execute_script safe_exec(self.report_script, None, loc) File "apps/frappe/frappe/utils/safe_exec.py", line 72, in safe_exec exec(compile_restricted(script), exec_globals, _locals) # pylint: disable=exec-used File "env/lib/python3.10/site-packages/RestrictedPython/compile.py", line 211, in compile_restricted raise SyntaxError(result.errors) SyntaxError: ("Line 1: SyntaxError: invalid character '“' (U+201C) at statement: 'result = frappe.db.get_all(“Item Price”,'",) ``` # Request Data ``` { "type": "GET", "args": { "report_name": "Item Price List", "filters": "{}", "are_default_filters": true }, "headers": {}, "error_handlers": {}, "url": "/api/method/frappe.desk.query_report.run" } ``` # Response Data ``` { "exception": "SyntaxError: ("Line 1: SyntaxError: invalid character '“' (U+201C) at statement: 'result = frappe.db.get_all(“Item Price”,'",)" } ```

answer:The traceback and response data indicate that the issue is related to the presence of invalid characters, specifically the double curly quotation marks (`“` and `”`), in the code snippet you provided. These characters are not valid in Python syntax. To fix the issue, replace the invalid quotation marks with regular double quotation marks (`"`). Here's the corrected code: ```python result = frappe.db.get_all("Item Price", fields=["*"], filters={"item_code": "item_code", "price_list": "price_list"}) ``` After replacing the invalid characters, save your script and try running the script report again. The issue should be resolved, and the script should execute without any syntax errors.

question:in report doctype there is part name client code < is this i should write here to filter run

answer:To filter the report's results based on the `client_code` field in the report doctype, you can modify your script as follows: ```python result = frappe.db.get_all("Item Price", fields=["*"], filters={"client_code": "<your_filter_value>"}) ``` Replace `<your_filter_value>` with the actual value you want to filter on. For example, if you want to filter the results where the `client_code` is equal to "ABC123", you would modify the code like this: ```python result = frappe.db.get_all("Item Price", fields=["*"], filters={"client_code": "ABC123"}) ``` Make sure to adjust the field name (`client_code`) and the desired filter value according to your specific requirements.

question:no there is text box in the bottom name client code

answer:Apologies for the confusion. If there is a textbox in the report UI for filtering based on the `client_code` field, you need to modify the script to use the value entered in the textbox as the filter. Here's an example of how you can achieve this: ```python # Get the filter value entered in the client code textbox client_code_filter = filters.get("client_code") # Use the filter value in the query result = frappe.db.get_all("Item Price", fields=["*"], filters={"client_code": client_code_filter}) ``` In the above code, `filters.get("client_code")` retrieves the value entered in the client code textbox from the `filters` dictionary. By using this filter value in the query, the results will be filtered based on the entered client code. Make sure to adjust the field name (`client_code`) based on the actual field in the document and its corresponding filter field in the report.

Released under the Watson License.

has loaded