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) #45856

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 0954aca into version-15-hotfix Feb 11, 2025
12 checks passed
@nabinhait nabinhait deleted the mergify/bp/version-15-hotfix/pr-45696 branch February 11, 2025 10:12
frappe-pr-bot pushed a commit that referenced this pull request Feb 12, 2025
# [15.52.0](v15.51.2...v15.52.0) (2025-02-12)

### Bug Fixes

* '0' rate LDC's Invoice net totals should be ignored ([96c19cd](96c19cd))
* add allow_on_submit for party_balance, paid_from_account_balance and paid_to_account_balance ([086c36f](086c36f))
* add precision in serial_batch_bundle.py ([a85f6f5](a85f6f5))
* add total row in non_grouped_invoices ([e432ae9](e432ae9))
* added validation for required invoice_fields in POS (backport [#45780](#45780)) ([#45868](#45868)) ([4f9a7f5](4f9a7f5))
* Attibute error `selling_price_list` ([6dc99f9](6dc99f9))
* changed naming series to random for SABB ([48a4eff](48a4eff))
* check_item_quality_inspection is not whitelisted ([0a4a093](0a4a093))
* correct amount in transaction currency for reverse gl entries (backport [#45794](#45794)) ([#45849](#45849)) ([b06bd82](b06bd82))
* correct amt in account currency for lcv with manually distributed charges. (backport [#45532](#45532)) ([#45864](#45864)) ([179cb1e](179cb1e))
* correct pay amount in portal pages ([3ada520](3ada520))
* create job card with wip warehouse set to source warehouse if material transfer to wip warehouse is skipped in work order ([9d6f318](9d6f318))
* do not allow "Finance Book" in Accounting Dimensions (backport [#45696](#45696)) ([#45856](#45856)) ([0954aca](0954aca))
* do not validate party against  Receivable and Payable account for cancelled gl entries ([6d777cd](6d777cd))
* dont update rate of free item on save ([1d3da4d](1d3da4d))
* handle response when json is None ([eeb322b](eeb322b))
* map project from rfq to supplier quotation (backport [#45745](#45745)) ([#45828](#45828)) ([b112d88](b112d88))
* not able to select the item in the sales invoice ([a649001](a649001))
* Party name in Supplier Portal for Purchase Order (backport [#45772](#45772)) ([#45858](#45858)) ([435c354](435c354))
* pos numpad editable action buttons (backport [#45823](#45823)) ([#45826](#45826)) ([035758f](035758f))
* possible model sync issue ([ea01fa1](ea01fa1))
* **regional:** removed payment schedule validation in sales invoice for italy (backport [#45852](#45852)) ([#45854](#45854)) ([2e9e355](2e9e355))
* remove serial no if qty is zero ([1359a77](1359a77))
* skip warning for free items ([2adab1d](2adab1d))
* stock reco current valuation rate ([3b7c38d](3b7c38d))
* the project document timed out while opening ([28cbce4](28cbce4))
* unable to remove image from employee ([e3cceb8](e3cceb8))
* update ctx to args ([d4bc3d1](d4bc3d1))

### Features

* add repost accounting ledger entry for payment entry ([757dd3f](757dd3f))
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 26, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs-tests This PR needs automated unit-tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants