Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions account_financial_report/report/abstract_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,11 @@ def _recalculate_move_lines(
return move_lines

def _get_accounts_data(self, accounts_ids):
accounts = self.env["account.account"].browse(accounts_ids)
accounts = (
self.env["account.account"]
.with_context(active_test=False)
.browse(accounts_ids)
)
accounts_data = {}
for account in accounts:
accounts_data.update(
Expand All @@ -143,8 +147,10 @@ def _get_accounts_data(self, accounts_ids):
return accounts_data

def _get_journals_data(self, journals_ids):
journals = self.env["account.journal"].search_fetch(
[("id", "in", journals_ids)], ["code"]
journals = (
self.env["account.journal"]
.with_context(active_test=False)
.search_fetch([("id", "in", journals_ids)], ["code"])
)
journals_data = {}
for journal in journals:
Expand Down
20 changes: 15 additions & 5 deletions account_financial_report/report/general_ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ def _get_analytic_data(self, account_ids):
return analytic_data

def _get_taxes_data(self, taxes_ids):
taxes = self.env["account.tax"].search_fetch(
[("id", "in", taxes_ids)], ["amount", "amount_type", "display_name"]
taxes = (
self.env["account.tax"]
.with_context(active_test=False)
.search_fetch(
[("id", "in", taxes_ids)], ["amount", "amount_type", "display_name"]
)
)
taxes_data = {}
for tax in taxes:
Expand Down Expand Up @@ -131,7 +135,11 @@ def _get_initial_balance_fy_pl_ml_domain(
domain = []
domain += base_domain
domain += [("date", "<", fy_start_date)]
accounts = self.env["account.account"].search(accounts_domain)
accounts = (
self.env["account.account"]
.with_context(active_test=False)
.search(accounts_domain)
)
domain += [("account_id", "in", accounts.ids)]
return domain

Expand Down Expand Up @@ -432,8 +440,10 @@ def _prepare_ml_items(self, move_line, grouped_by):
res.append({"id": item_id, "name": item_name})
elif move_line["tax_ids"]:
for tax_id in move_line["tax_ids"]:
tax_item = self.env["account.tax"].search_fetch(
[("id", "=", tax_id)], ["name"]
tax_item = (
self.env["account.tax"]
.with_context(active_test=False)
.search_fetch([("id", "=", tax_id)], ["name"])
)
res.append({"id": tax_item.id, "name": tax_item.name})
else:
Expand Down
16 changes: 11 additions & 5 deletions account_financial_report/report/journal_ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@ def _get_journal_ledgers_domain(self, wizard, journal_ids, company):
return domain

def _get_journal_ledgers(self, wizard, journal_ids, company):
journals = self.env["account.journal"].search(
self._get_journal_ledgers_domain(wizard, journal_ids, company),
order="name asc",
journals = (
self.env["account.journal"]
.with_context(active_test=False)
.search(
self._get_journal_ledgers_domain(wizard, journal_ids, company),
order="name asc",
)
)
journal_ledgers_data = []
for journal in journals:
Expand Down Expand Up @@ -264,8 +268,10 @@ def _get_journal_tax_lines(self, wizard, moves_data):
journal_id = ml_data["journal_id"]
if journal_id not in journals_taxes_data.keys():
journals_taxes_data[journal_id] = {}
taxes = self.env["account.tax"].search_fetch(
[("id", "in", tax_ids)], ["name", "description"]
taxes = (
self.env["account.tax"]
.with_context(active_test=False)
.search_fetch([("id", "in", tax_ids)], ["name", "description"])
)
for tax in taxes:
if tax.id not in journals_taxes_data[journal_id]:
Expand Down
12 changes: 10 additions & 2 deletions account_financial_report/report/journal_ledger_xlsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,11 @@ def _generate_no_group_content(self, workbook, report, res_data, report_data):
def _generate_journal_content(
self, workbook, report, res_data, ledger, report_data
):
journal = self.env["account.journal"].browse(ledger["id"])
journal = (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is loading a journal, so are you sure you require the context here?

self.env["account.journal"]
.with_context(active_test=False)
.browse(ledger["id"])
)
currency_name = (
journal.currency_id
and journal.currency_id.name
Expand All @@ -196,7 +200,11 @@ def _generate_no_group_taxes_summary(self, workbook, report, res_data, report_da
)

def _generate_journal_taxes_summary(self, workbook, ledger, report_data):
journal = self.env["account.journal"].browse(ledger["id"])
journal = (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same for this one.

self.env["account.journal"]
.with_context(active_test=False)
.browse(ledger["id"])
)
currency_name = (
journal.currency_id
and journal.currency_id.name
Expand Down
30 changes: 25 additions & 5 deletions account_financial_report/report/trial_balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ def _get_initial_balances_bs_ml_domain(
if account_ids:
accounts_domain += [("id", "in", account_ids)]
domain = [("date", "<", date_from)]
accounts = self.env["account.account"].search(accounts_domain)
accounts = (
self.env["account.account"]
.with_context(active_test=False)
.search(accounts_domain)
)
domain += [("account_id", "in", accounts.ids)]
if company_id:
domain += [("company_id", "=", company_id)]
Expand Down Expand Up @@ -71,7 +75,11 @@ def _get_initial_balances_pl_ml_domain(
if account_ids:
accounts_domain += [("id", "in", account_ids)]
domain = [("date", "<", date_from), ("date", ">=", fy_start_date)]
accounts = self.env["account.account"].search(accounts_domain)
accounts = (
self.env["account.account"]
.with_context(active_test=False)
.search(accounts_domain)
)
domain += [("account_id", "in", accounts.ids)]
if company_id:
domain += [("company_id", "=", company_id)]
Expand Down Expand Up @@ -149,7 +157,11 @@ def _get_initial_balance_fy_pl_ml_domain(
if account_ids:
accounts_domain += [("id", "in", account_ids)]
domain = [("date", "<", fy_start_date)]
accounts = self.env["account.account"].search(accounts_domain)
accounts = (
self.env["account.account"]
.with_context(active_test=False)
.search(accounts_domain)
)
domain += [("account_id", "in", accounts.ids)]
if company_id:
domain += [("company_id", "=", company_id)]
Expand Down Expand Up @@ -426,7 +438,11 @@ def _get_data(
# If explicit list of accounts is provided,
# don't include unaffected earnings account
unaffected_earnings_account = False
accounts = self.env["account.account"].search(accounts_domain)
accounts = (
self.env["account.account"]
.with_context(active_test=False)
.search(accounts_domain)
)
tb_initial_acc = []
for account in accounts:
tb_initial_acc.append(
Expand Down Expand Up @@ -746,7 +762,11 @@ def _get_hierarchy_groups(self, group_ids, groups_data, foreign_currency):

def _get_groups_data(self, accounts_data, total_amount, foreign_currency):
accounts_ids = list(accounts_data.keys())
accounts = self.env["account.account"].browse(accounts_ids)
accounts = (
self.env["account.account"]
.with_context(active_test=False)
.browse(accounts_ids)
)
account_group_relation = {}
for account in accounts:
accounts_data[account.id]["complete_code"] = (
Expand Down
2 changes: 1 addition & 1 deletion account_financial_report/report/vat_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class VATReport(models.AbstractModel):
_description = "Vat Report Report"

def _get_tax_data(self, tax_ids):
taxes = self.env["account.tax"].browse(tax_ids)
taxes = self.env["account.tax"].with_context(active_test=False).browse(tax_ids)
tax_data = {}
for tax in taxes:
tax_data.update(
Expand Down
6 changes: 4 additions & 2 deletions account_financial_report/wizard/journal_ledger_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@ def _prepare_report_journal_ledger(self):
journals = self.journal_ids
if not journals:
# Not selecting a journal means that we'll display all journals
journals = self.env["account.journal"].search(
[("company_id", "=", self.company_id.id)]
journals = (
self.env["account.journal"]
.with_context(active_test=False)
.search([("company_id", "=", self.company_id.id)])
)
return {
"wizard_id": self.id,
Expand Down