From e2af66c7beab2e1fd51e221f7440cb14ab15a316 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Sat, 6 May 2023 17:44:49 +0530 Subject: [PATCH] fix: handle empty FBs properly in TB and GL [v14] (backport #35189) (#35192) fix: handle empty FBs properly in TB and GL [v14] (#35189) fix: handle empty FBs properly in TB and GL (cherry picked from commit ed5f39c2c2f7cb960e0cccac80b252cdce1077cf) Co-authored-by: Anand Baburajan --- erpnext/accounts/report/financial_statements.py | 12 ++++++++---- .../accounts/report/general_ledger/general_ledger.py | 8 ++++---- .../accounts/report/trial_balance/trial_balance.py | 10 ++++++---- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py index d61330e0cfb6..03ae13c53a4c 100644 --- a/erpnext/accounts/report/financial_statements.py +++ b/erpnext/accounts/report/financial_statements.py @@ -532,14 +532,18 @@ def get_additional_conditions(from_date, ignore_closing_entries, filters): _("To use a different finance book, please uncheck 'Include Default Book Entries'") ) else: - additional_conditions.append("(finance_book in (%(finance_book)s) OR finance_book IS NULL)") + additional_conditions.append( + "(finance_book in (%(finance_book)s, '') OR finance_book IS NULL)" + ) else: - additional_conditions.append("(finance_book in (%(company_fb)s) OR finance_book IS NULL)") + additional_conditions.append("(finance_book in (%(company_fb)s, '') OR finance_book IS NULL)") else: if filters.get("finance_book"): - additional_conditions.append("(finance_book in (%(finance_book)s) OR finance_book IS NULL)") + additional_conditions.append( + "(finance_book in (%(finance_book)s, '') OR finance_book IS NULL)" + ) else: - additional_conditions.append("(finance_book IS NULL)") + additional_conditions.append("(finance_book in ('') OR finance_book IS NULL)") if accounting_dimensions: for dimension in accounting_dimensions: diff --git a/erpnext/accounts/report/general_ledger/general_ledger.py b/erpnext/accounts/report/general_ledger/general_ledger.py index 34534f883ed0..410883708971 100644 --- a/erpnext/accounts/report/general_ledger/general_ledger.py +++ b/erpnext/accounts/report/general_ledger/general_ledger.py @@ -296,14 +296,14 @@ def get_conditions(filters): _("To use a different finance book, please uncheck 'Include Default Book Entries'") ) else: - conditions.append("(finance_book in (%(finance_book)s) OR finance_book IS NULL)") + conditions.append("(finance_book in (%(finance_book)s, '') OR finance_book IS NULL)") else: - conditions.append("(finance_book in (%(company_fb)s) OR finance_book IS NULL)") + conditions.append("(finance_book in (%(company_fb)s, '') OR finance_book IS NULL)") else: if filters.get("finance_book"): - conditions.append("(finance_book in (%(finance_book)s) OR finance_book IS NULL)") + conditions.append("(finance_book in (%(finance_book)s, '') OR finance_book IS NULL)") else: - conditions.append("(finance_book IS NULL)") + conditions.append("(finance_book in ('') OR finance_book IS NULL)") if not filters.get("show_cancelled_entries"): conditions.append("is_cancelled = 0") diff --git a/erpnext/accounts/report/trial_balance/trial_balance.py b/erpnext/accounts/report/trial_balance/trial_balance.py index d2300cd12389..3bcd1bc68d03 100644 --- a/erpnext/accounts/report/trial_balance/trial_balance.py +++ b/erpnext/accounts/report/trial_balance/trial_balance.py @@ -166,14 +166,16 @@ def get_rootwise_opening_balances(filters, report_type): _("To use a different finance book, please uncheck 'Include Default Book Entries'") ) else: - additional_conditions += " AND (finance_book in (%(finance_book)s) OR finance_book IS NULL)" + additional_conditions += ( + " AND (finance_book in (%(finance_book)s, '') OR finance_book IS NULL)" + ) else: - additional_conditions += " AND (finance_book in (%(company_fb)s) OR finance_book IS NULL)" + additional_conditions += " AND (finance_book in (%(company_fb)s, '') OR finance_book IS NULL)" else: if filters.get("finance_book"): - additional_conditions += " AND (finance_book in (%(finance_book)s) OR finance_book IS NULL)" + additional_conditions += " AND (finance_book in (%(finance_book)s, '') OR finance_book IS NULL)" else: - additional_conditions += " AND (finance_book IS NULL)" + additional_conditions += " AND (finance_book in ('') OR finance_book IS NULL)" accounting_dimensions = get_accounting_dimensions(as_list=False)