frappe / crm

The future of open source CRM
https://frappe.io/crm
GNU Affero General Public License v3.0
333 stars 162 forks source link

DataError: Field not permitted in query: enabled #244

Closed giulio-perosino closed 3 months ago

giulio-perosino commented 3 months ago

Hello,

I'm encountering an issue with the Frappe CRM. When entering the single lead page, I get the following error:

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 114, 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 1808, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/utils/typing_validations.py", line 32, in wrapper
    return func(*args, **kwargs)
  File "apps/frappe/frappe/client.py", line 66, in get_list
    validate_args(args)
  File "apps/frappe/frappe/desk/reportview.py", line 93, in validate_args
    validate_fields(data)
  File "apps/frappe/frappe/desk/reportview.py", line 121, in validate_fields
    raise_invalid_field(fieldname)
  File "apps/frappe/frappe/desk/reportview.py", line 182, in raise_invalid_field
    frappe.throw(_("Field not permitted in query") + f": {fieldname}", frappe.DataError)
  File "apps/frappe/frappe/__init__.py", line 681, in throw
    msgprint(
  File "apps/frappe/frappe/__init__.py", line 646, in msgprint
    _raise_exception()
  File "apps/frappe/frappe/__init__.py", line 597, in _raise_exception
    raise exc
frappe.exceptions.DataError: Field not permitted in query: enabled

I'm not sure why the field 'enabled' is not permitted in the query. Any help on how to resolve this would be greatly appreciated.

Thank you!

shariquerik commented 3 months ago

@giulio-perosino Can you share a screen recording of the issue. I am not able to reproduce the issue.

giulio-perosino commented 3 months ago

@shariquerik here you go. Happens also when creating a new Lead

https://github.com/frappe/crm/assets/109590131/0f954cff-9e11-42f9-a88c-d8a28f58975a

shariquerik commented 3 months ago

Can you check if there is CRM Fields Layout Check in desk

shariquerik commented 3 months ago
image

Run this in console it should fix your issue

giulio-perosino commented 3 months ago

Thanks, Shariq! This fixed the issue. I couldn’t find these steps in the docs, maybe I missed them.

giulio-perosino commented 3 months ago

Apologies for re-opening this issue, but I encounter a similar error on the "Contacts" page. Are there additional steps required after installing the app?

Thanks 🙏

12:38:34 web.1      | Traceback (most recent call last):
12:38:34 web.1      |   File "apps/frappe/frappe/app.py", line 114, in application
12:38:34 web.1      |     response = frappe.api.handle(request)
12:38:34 web.1      |                ^^^^^^^^^^^^^^^^^^^^^^^^^^
12:38:34 web.1      |   File "apps/frappe/frappe/api/__init__.py", line 49, in handle
12:38:34 web.1      |     data = endpoint(**arguments)
12:38:34 web.1      |            ^^^^^^^^^^^^^^^^^^^^^
12:38:34 web.1      |   File "apps/frappe/frappe/api/v1.py", line 36, in handle_rpc_call
12:38:34 web.1      |     return frappe.handler.handle()
12:38:34 web.1      |            ^^^^^^^^^^^^^^^^^^^^^^^
12:38:34 web.1      |   File "apps/frappe/frappe/handler.py", line 49, in handle
12:38:34 web.1      |     data = execute_cmd(cmd)
12:38:34 web.1      |            ^^^^^^^^^^^^^^^^
12:38:34 web.1      |   File "apps/frappe/frappe/handler.py", line 85, in execute_cmd
12:38:34 web.1      |     return frappe.call(method, **frappe.form_dict)
12:38:34 web.1      |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12:38:34 web.1      |   File "apps/frappe/frappe/__init__.py", line 1808, in call
12:38:34 web.1      |     return fn(*args, **newargs)
12:38:34 web.1      |            ^^^^^^^^^^^^^^^^^^^^
12:38:34 web.1      |   File "apps/frappe/frappe/utils/typing_validations.py", line 32, in wrapper
12:38:34 web.1      |     return func(*args, **kwargs)
12:38:34 web.1      |            ^^^^^^^^^^^^^^^^^^^^^
12:38:34 web.1      |   File "apps/crm/crm/fcrm/doctype/crm_fields_layout/crm_fields_layout.py", line 38, in get_fields_layout
12:38:34 web.1      |     field.options = field.options.split("\n")
12:38:34 web.1      |                     ^^^^^^^^^^^^^^^^^^^
12:38:34 web.1      | AttributeError: 'list' object has no attribute 'split'
12:38:34 web.1      | 
12:38:34 web.1      | 172.18.0.1 - - [10/Jul/2024 12:38:34] "POST /api/method/crm.fcrm.doctype.crm_fields_layout.crm_fields_layout.get_fields_layout HTTP/1.1" 500 -
giulio-perosino commented 3 months ago

I've identified the problem. The after_install() function failed to execute upon app installation, resulting in the absence of Quick Entry Layouts in the database. Consequently, I created a new layout for the Contact page. However, when I executed the scripts as Shariq suggested (https://github.com/frappe/crm/issues/244#issuecomment-2219927138), the database fields were not overwritten with the default one, which led to the issue.

To resolve the issue, I replaced the layout field values directly in the database.