frappe / erpnext

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

Error on Purchase/Sales Analytics Report - Item Group #25023

Open asoral opened 3 years ago

asoral commented 3 years ago

When I open the sale/purchase analytics report and select "Item Group" to group by on I get this error

Traceback (most recent call last): File "/home/erpnext/frappe-bench/apps/frappe/frappe/app.py", line 67, in application response = frappe.api.handle() File "/home/erpnext/frappe-bench/apps/frappe/frappe/api.py", line 58, in handle return frappe.handler.handle() File "/home/erpnext/frappe-bench/apps/frappe/frappe/handler.py", line 30, in handle data = execute_cmd(cmd) File "/home/erpnext/frappe-bench/apps/frappe/frappe/handler.py", line 70, in execute_cmd return frappe.call(method, frappe.form_dict) File "/home/erpnext/frappe-bench/apps/frappe/frappe/init.py", line 1134, in call return fn(*args, *newargs) File "/home/erpnext/frappe-bench/apps/frappe/frappe/init.py", line 566, in wrapper_fn retval = fn(args, get_newargs(fn, kwargs)) File "/home/erpnext/frappe-bench/apps/frappe/frappe/desk/query_report.py", line 227, in run result = generate_report_result(report, filters, user, custom_columns) File "/home/erpnext/frappe-bench/apps/frappe/frappe/desk/query_report.py", line 75, in generate_report_result res = report.execute_script_report(filters) File "/home/erpnext/frappe-bench/apps/frappe/frappe/core/doctype/report/report.py", line 124, in execute_script_report res = self.execute_module(filters) File "/home/erpnext/frappe-bench/apps/frappe/frappe/core/doctype/report/report.py", line 141, in execute_module return frappe.get_attr(method_name)(frappe._dict(filters)) File "/home/erpnext/frappe-bench/apps/erpnext/erpnext/buying/report/purchase_analytics/purchase_analytics.py", line 8, in execute return Analytics(filters).run() File "/home/erpnext/frappe-bench/apps/erpnext/erpnext/selling/report/sales_analytics/sales_analytics.py", line 24, in run self.get_data() File "/home/erpnext/frappe-bench/apps/erpnext/erpnext/selling/report/sales_analytics/sales_analytics.py", line 90, in get_data self.get_sales_transactions_based_on_item_group() File "/home/erpnext/frappe-bench/apps/erpnext/erpnext/selling/report/sales_analytics/sales_analytics.py", line 203, in get_sales_transactions_based_on_item_group self.get_groups() File "/home/erpnext/frappe-bench/apps/erpnext/erpnext/selling/report/sales_analytics/sales_analytics.py", line 347, in get_groups self.depth_map.setdefault(d.name, self.depth_map.get(d.parent) + 1) TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'

Anuja-pawar commented 3 years ago

We can't replicate it. Can you please confirm if you're still facing this issue? If yes, please share a screenshot/GIF if possible.

asoral commented 3 years ago

![Uploading Screenshot_20210411-095837_Edge.jpg…]()

ahmederp commented 2 years ago

I am facing the same issue.

ahmederp commented 2 years ago

App Versions

{
    "erpnext": "14.0.3",
    "frappe": "14.5.0"
}

Route

query-report/Sales Analytics

Trackeback

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 69, 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 1599, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/__init__.py", line 783, in wrapper_fn
    retval = fn(*args, **get_newargs(fn, kwargs))
  File "apps/frappe/frappe/desk/query_report.py", line 253, in run
    result = generate_report_result(report, filters, user, custom_columns, is_tree, parent_field)
  File "apps/frappe/frappe/__init__.py", line 783, in wrapper_fn
    retval = fn(*args, **get_newargs(fn, kwargs))
  File "apps/frappe/frappe/desk/query_report.py", line 87, in generate_report_result
    res = get_report_result(report, filters) or []
  File "apps/frappe/frappe/desk/query_report.py", line 68, in get_report_result
    res = report.execute_script_report(filters)
  File "apps/frappe/frappe/core/doctype/report/report.py", line 142, in execute_script_report
    res = self.execute_module(filters)
  File "apps/frappe/frappe/core/doctype/report/report.py", line 159, in execute_module
    return frappe.get_attr(method_name)(frappe._dict(filters))
  File "apps/erpnext/erpnext/selling/report/sales_analytics/sales_analytics.py", line 13, in execute
    return Analytics(filters).run()
  File "apps/erpnext/erpnext/selling/report/sales_analytics/sales_analytics.py", line 42, in run
    self.get_data()
  File "apps/erpnext/erpnext/selling/report/sales_analytics/sales_analytics.py", line 108, in get_data
    self.get_sales_transactions_based_on_item_group()
  File "apps/erpnext/erpnext/selling/report/sales_analytics/sales_analytics.py", line 236, in get_sales_transactions_based_on_item_group
    self.get_groups()
  File "apps/erpnext/erpnext/selling/report/sales_analytics/sales_analytics.py", line 380, in get_groups
    self.depth_map.setdefault(d.name, self.depth_map.get(d.parent) + 1)
TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'

Request Data

{
    "type": "GET",
    "args": {
        "report_name": "Sales Analytics",
        "filters": "{\"tree_type\":\"Item Group\",\"doc_type\":\"Sales Invoice\",\"value_quantity\":\"Value\",\"from_date\":\"2022-01-01\",\"to_date\":\"2022-12-31\",\"company\":\"ASSET For Industrial & Energy Solutions LLC\",\"range\":\"Monthly\"}"
    },
    "headers": {},
    "error_handlers": {},
    "url": "/api/method/frappe.desk.query_report.run"
}

Response Data

{
    "exception": "TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'"
}