frappe / erpnext

Free and Open Source Enterprise Resource Planning (ERP)
https://erpnext.com
GNU General Public License v3.0
21.88k stars 7.33k forks source link

Item table alias not unique #35304

Closed bhickta closed 1 year ago

bhickta commented 1 year ago

Information about bug

pymysql.err.OperationalError: (1066, "Not unique table/alias: 'tabItem'")

Module

stock

Version

Erpnext version

Installation method

manual install

Relevant log output / Stack trace / Full Error Message.

### App Versions

{
    "erpnext": "14.24.1",
    "frappe": "14.36.0",
    "frappe_whatsapp": "0.0.2",
    "india_compliance": "14.6.1",
    "payments": "0.0.1",
    "raplbaddi": "0.0.1"
}

Route

List/Item/List

Traceback

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 66, 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 45, in handle
    data = execute_cmd(cmd)
  File "apps/frappe/frappe/handler.py", line 83, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "apps/frappe/frappe/__init__.py", line 1607, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/__init__.py", line 789, in wrapper_fn
    retval = fn(*args, **get_newargs(fn, kwargs))
  File "apps/frappe/frappe/desk/reportview.py", line 29, in get
    data = compress(execute(**args), args=args)
  File "apps/frappe/frappe/desk/reportview.py", line 65, in execute
    return DatabaseQuery(doctype).execute(*args, **kwargs)
  File "apps/frappe/frappe/model/db_query.py", line 202, in execute
    result = self.build_and_run()
  File "apps/frappe/frappe/model/db_query.py", line 242, in build_and_run
    return frappe.db.sql(
  File "apps/frappe/frappe/database/database.py", line 219, in sql
    self._cursor.execute(query, values)
  File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 158, in execute
    result = self._query(query)
  File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 325, in _query
    conn.query(q)
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 549, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 779, in _read_query_result
    result.read()
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 1157, in read
    first_packet = self.connection._read_packet()
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 729, in _read_packet
    packet.raise_for_error()
  File "env/lib/python3.10/site-packages/pymysql/protocol.py", line 221, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "env/lib/python3.10/site-packages/pymysql/err.py", line 143, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.OperationalError: (1066, "Not unique table/alias: 'tabItem'")

Request Data

{
    "type": "POST",
    "args": {
        "doctype": "Item",
        "fields": "[\"`tabItem`.`name`\",\"`tabItem`.`owner`\",\"`tabItem`.`creation`\",\"`tabItem`.`modified`\",\"`tabItem`.`modified_by`\",\"`tabItem`.`_user_tags`\",\"`tabItem`.`_comments`\",\"`tabItem`.`_assign`\",\"`tabItem`.`_liked_by`\",\"`tabItem`.`docstatus`\",\"`tabItem`.`idx`\",\"`tabItem`.`item_name`\",\"`tabItem`.`stock_uom`\",\"`tabItem`.`image`\",\"`tabItem`.`item_group`\",\"`tabItem`.`variant_of`\",\"`tabItem`.`has_variants`\",\"`tabItem`.`end_of_life`\",\"`tabItem`.`disabled`\",\"variant_of.item_name as variant_of_item_name\"]",
        "filters": "[[\"Item\",\"disabled\",\"=\",0]]",
        "order_by": "`tabItem`.`modified` desc",
        "start": 0,
        "page_length": 20,
        "view": "List",
        "group_by": "`tabItem`.`name`",
        "with_comment_count": true
    },
    "freeze": false,
    "freeze_message": "Loading...",
    "headers": {},
    "error_handlers": {},
    "url": "/api/method/frappe.desk.reportview.get"
}

Response Data

{
    "exception": "pymysql.err.OperationalError: (1066, \"Not unique table/alias: 'tabItem'\")"
}
bhickta commented 1 year ago

Had to disable: --> Show title in link field image

But why this option is not working