Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not allow "Finance Book" in Accounting Dimensions (backport #45696) #45855

Merged
merged 1 commit into from
Feb 11, 2025

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Feb 11, 2025

Issue: The user created the Finance book as Accounting Dimensions which is already a default dimension causing errors in the report because the accounting dimension is multi-select and the finance book field is a Link field.

App Versions

{
	"erpnext": "15.35.1",
	"frappe": "15.40.6",
	"hrms": "15.28.3",
	"lending": "0.0.1",
	"ls_treso": "0.0.1",
	"paie": "0.0.1",
	"print_designer": "1.4.2"
}

Route

query-report/Trial Balance

Traceback

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 1775, in call
    return fn(*args, **newargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 928, in wrapper_fn
    retval = fn(*args, **get_newargs(fn, kwargs))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/desk/query_report.py", line 223, in run
    result = generate_report_result(report, filters, user, custom_columns, is_tree, parent_field)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 928, in wrapper_fn
    retval = fn(*args, **get_newargs(fn, kwargs))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/desk/query_report.py", line 84, in generate_report_result
    res = get_report_result(report, filters) or []
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/desk/query_report.py", line 65, in get_report_result
    res = report.execute_script_report(filters)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/core/doctype/report/report.py", line 163, in execute_script_report
    res = self.execute_module(filters)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/core/doctype/report/report.py", line 180, in execute_module
    return frappe.get_attr(method_name)(frappe._dict(filters))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/erpnext/erpnext/accounts/report/trial_balance/trial_balance.py", line 34, in execute
    data = get_data(filters)
           ^^^^^^^^^^^^^^^^^
  File "apps/erpnext/erpnext/accounts/report/trial_balance/trial_balance.py", line 105, in get_data
    opening_balances = get_opening_balances(filters)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/erpnext/erpnext/accounts/report/trial_balance/trial_balance.py", line 135, in get_opening_balances
    balance_sheet_opening = get_rootwise_opening_balances(filters, "Balance Sheet")
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/erpnext/erpnext/accounts/report/trial_balance/trial_balance.py", line 177, in get_rootwise_opening_balances
    gle = get_opening_balance("GL Entry", filters, report_type, accounting_dimensions)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/erpnext/erpnext/accounts/report/trial_balance/trial_balance.py", line 295, in get_opening_balance
    opening_balance = opening_balance.where(
                      ^^^^^^^^^^^^^^^^^^^^^^
  File "env/lib/python3.11/site-packages/pypika/utils.py", line 50, in _copy
    result = func(self_copy, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "env/lib/python3.11/site-packages/pypika/queries.py", line 930, in where
    if not self._validate_table(criterion):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "env/lib/python3.11/site-packages/pypika/queries.py", line 1155, in _validate_table
    for field in term.fields_():
                 ^^^^^^^^^^^^^^
  File "env/lib/python3.11/site-packages/pypika/terms.py", line 57, in fields_
    return set(self.find_(Field))
               ^^^^^^^^^^^^^^^^^
  File "env/lib/python3.11/site-packages/pypika/terms.py", line 37, in find_
    return [node for node in self.nodes_() if isinstance(node, type)]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "env/lib/python3.11/site-packages/pypika/terms.py", line 37, in <listcomp>
    return [node for node in self.nodes_() if isinstance(node, type)]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "env/lib/python3.11/site-packages/pypika/terms.py", line 795, in nodes_
    yield from self.container.nodes_()
               ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'nodes_'

Request Data

{
	"type": "GET",
	"args": {
		"report_name": "Trial Balance",
		"filters": "{\"company\":\"Institut Congolais pour la Conservation de la Nature (ICCN)\",\"fiscal_year\":\"2024\",\"from_date\":\"2024-01-01\",\"to_date\":\"2024-12-31\",\"programme\":[],\"imputation_analytique_2\":[],\"branch\":[],\"finance_book\":\"311OD1\",\"with_period_closing_entry_for_opening\":1,\"with_period_closing_entry_for_current_period\":1,\"include_default_book_entries\":1,\"show_net_values\":1}",
		"ignore_prepared_report": false,
		"is_tree": true,
		"parent_field": "parent_account",
		"are_default_filters": false
	},
	"headers": {},
	"error_handlers": {},
	"url": "/api/method/frappe.desk.query_report.run",
	"request_id": "fcd87219-a9a7-4054-be8a-d13140a4826f"
}

Response Data

{
	"exception": "AttributeError: 'str' object has no attribute 'nodes_'",
	"exc_type": "AttributeError",
	"_exc_source": "erpnext (app)"
}

Frappe Support Issue: https://support.frappe.io/app/hd-ticket/27798


This is an automatic backport of pull request #45696 done by [Mergify](https://mergify.com).

@github-actions github-actions bot added the needs-tests This PR needs automated unit-tests. label Feb 11, 2025
@nabinhait nabinhait merged commit 08ba775 into version-14-hotfix Feb 11, 2025
11 checks passed
@nabinhait nabinhait deleted the mergify/bp/version-14-hotfix/pr-45696 branch February 11, 2025 10:12
frappe-pr-bot pushed a commit that referenced this pull request Feb 12, 2025
## [14.82.2](v14.82.1...v14.82.2) (2025-02-12)

### Bug Fixes

* add total row in non_grouped_invoices ([49074aa](49074aa))
* correct amt in account currency for lcv with manually distributed charges. (backport [#45532](#45532)) ([#45863](#45863)) ([c61e4e2](c61e4e2))
* do not allow "Finance Book" in Accounting Dimensions (backport [#45696](#45696)) ([#45855](#45855)) ([08ba775](08ba775))
* do not validate party against  Receivable and Payable account for cancelled gl entries ([9f79da0](9f79da0))
* map project from rfq to supplier quotation (backport [#45745](#45745)) ([#45827](#45827)) ([c4358c0](c4358c0))
* Party name in Supplier Portal for Purchase Order (backport [#45772](#45772)) ([#45857](#45857)) ([46eba50](46eba50))
* pos numpad editable action buttons (backport [#45823](#45823)) ([#45825](#45825)) ([6b9dad7](6b9dad7))
* **regional:** removed payment schedule validation in sales invoice for italy (backport [#45852](#45852)) ([#45853](#45853)) ([de14bf1](de14bf1))
* skip warning for free items ([2ed3bdc](2ed3bdc))
* unable to remove image from employee ([91caca0](91caca0))
* update ctx to args ([573ce64](573ce64))

### Performance Improvements

* Ignore is_opening column in GL Queries ([#45327](#45327)) ([9985a03](9985a03))
@frappe-pr-bot
Copy link
Collaborator

🎉 This PR is included in version 14.82.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-tests This PR needs automated unit-tests. released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants