[IMP] account_financial_report: Allow user cut label string of account move line in reports

pull/1281/head
sergio-teruel 2025-02-05 18:55:49 +01:00
parent 0d663b5fa7
commit 7fc9917f3e
27 changed files with 307 additions and 231 deletions

View File

@ -160,3 +160,9 @@ class AgedPartnerBalanceReport(models.AbstractModel):
"debit",
"amount_currency",
]
def _get_report_values(self, docids, data):
wizard = self.env[data["wizard_name"]].browse(data["wizard_id"])
return {
"limit_text": wizard._limit_text,
}

View File

@ -437,6 +437,7 @@ class AgedPartnerBalanceReport(models.AbstractModel):
return aged_partner_data
def _get_report_values(self, docids, data):
res = super()._get_report_values(docids, data)
wizard_id = data["wizard_id"]
company = self.env["res.company"].browse(data["company_id"])
company_id = data["company_id"]
@ -478,18 +479,21 @@ class AgedPartnerBalanceReport(models.AbstractModel):
aged_partner_data = self.with_context(
age_partner_config=aged_partner_configuration
)._calculate_percent(aged_partner_data)
return {
"doc_ids": [wizard_id],
"doc_model": "open.items.report.wizard",
"docs": self.env["open.items.report.wizard"].browse(wizard_id),
"company_name": company.display_name,
"currency_name": company.currency_id.name,
"date_at": date_at,
"only_posted_moves": only_posted_moves,
"aged_partner_balance": aged_partner_data,
"show_move_lines_details": show_move_line_details,
"age_partner_config": aged_partner_configuration,
}
res.update(
{
"doc_ids": [wizard_id],
"doc_model": "open.items.report.wizard",
"docs": self.env["open.items.report.wizard"].browse(wizard_id),
"company_name": company.display_name,
"currency_name": company.currency_id.name,
"date_at": date_at,
"only_posted_moves": only_posted_moves,
"aged_partner_balance": aged_partner_data,
"show_move_lines_details": show_move_line_details,
"age_partner_config": aged_partner_configuration,
}
)
return res
def _get_ml_fields(self):
return self.COMMON_ML_FIELDS + [

View File

@ -776,6 +776,7 @@ class GeneralLedgerReport(models.AbstractModel):
# flake8: noqa: C901
def _get_report_values(self, docids, data):
res = super()._get_report_values(docids, data)
wizard_id = data["wizard_id"]
wizard = self.env["general.ledger.report.wizard"].browse(wizard_id)
company = wizard.company_id
@ -909,30 +910,33 @@ class GeneralLedgerReport(models.AbstractModel):
if not gl_item["currency_id"] and len(fin_bal_currency_ids) == 1:
fin_bal_currency_id = fin_bal_currency_ids[0]
gl_item["fin_bal_currency_id"] = fin_bal_currency_id
return {
"doc_ids": [wizard_id],
"doc_model": "general.ledger.report.wizard",
"docs": wizard,
"foreign_currency": foreign_currency,
"company_name": company.display_name,
"company_currency": company.currency_id,
"currency_name": company.currency_id.name,
"date_from": date_from,
"date_to": date_to,
"only_posted_moves": only_posted_moves,
"hide_account_at_0": hide_account_at_0,
"show_analytic_tags": wizard.show_analytic_tags,
"show_cost_center": wizard.show_cost_center,
"general_ledger": general_ledger,
"accounts_data": accounts_data,
"journals_data": journals_data,
"full_reconcile_data": full_reconcile_data,
"taxes_data": taxes_data,
"centralize": centralize,
"tags_data": tags_data,
"filter_partner_ids": True if partner_ids else False,
"currency_model": self.env["res.currency"],
}
res.update(
{
"doc_ids": [wizard_id],
"doc_model": "general.ledger.report.wizard",
"docs": wizard,
"foreign_currency": foreign_currency,
"company_name": company.display_name,
"company_currency": company.currency_id,
"currency_name": company.currency_id.name,
"date_from": date_from,
"date_to": date_to,
"only_posted_moves": only_posted_moves,
"hide_account_at_0": hide_account_at_0,
"show_analytic_tags": wizard.show_analytic_tags,
"show_cost_center": wizard.show_cost_center,
"general_ledger": general_ledger,
"accounts_data": accounts_data,
"journals_data": journals_data,
"full_reconcile_data": full_reconcile_data,
"taxes_data": taxes_data,
"centralize": centralize,
"tags_data": tags_data,
"filter_partner_ids": True if partner_ids else False,
"currency_model": self.env["res.currency"],
}
)
return res
def _get_ml_fields(self):
return self.COMMON_ML_FIELDS + [

View File

@ -8,6 +8,7 @@ from odoo import models
class JournalLedgerReport(models.AbstractModel):
_inherit = "report.account_financial_report.abstract_report"
_name = "report.account_financial_report.journal_ledger"
_description = "Journal Ledger Report"
@ -296,6 +297,7 @@ class JournalLedgerReport(models.AbstractModel):
return journals_taxes_data_2
def _get_report_values(self, docids, data):
res = super()._get_report_values(docids, data)
wizard_id = data["wizard_id"]
wizard = self.env["journal.ledger.report.wizard"].browse(wizard_id)
company = self.env["res.company"].browse(data["company_id"])
@ -349,25 +351,28 @@ class JournalLedgerReport(models.AbstractModel):
if journal_id in journal_totals.keys():
for item in ["debit", "credit"]:
journal_ledger_data[item] += journal_totals[journal_id][item]
return {
"doc_ids": [wizard_id],
"doc_model": "journal.ledger.report.wizard",
"docs": self.env["journal.ledger.report.wizard"].browse(wizard_id),
"group_option": data["group_option"],
"foreign_currency": data["foreign_currency"],
"with_account_name": data["with_account_name"],
"company_name": company.display_name,
"currency_name": company.currency_id.name,
"date_from": data["date_from"],
"date_to": data["date_to"],
"move_target": data["move_target"],
"with_auto_sequence": data["with_auto_sequence"],
"account_ids_data": account_ids_data,
"partner_ids_data": partner_ids_data,
"currency_ids_data": currency_ids_data,
"move_ids_data": move_ids_data,
"tax_line_data": tax_line_ids_data,
"move_line_ids_taxes_data": move_line_ids_taxes_data,
"Journal_Ledgers": journal_ledgers_data,
"Moves": moves_data,
}
res.update(
{
"doc_ids": [wizard_id],
"doc_model": "journal.ledger.report.wizard",
"docs": self.env["journal.ledger.report.wizard"].browse(wizard_id),
"group_option": data["group_option"],
"foreign_currency": data["foreign_currency"],
"with_account_name": data["with_account_name"],
"company_name": company.display_name,
"currency_name": company.currency_id.name,
"date_from": data["date_from"],
"date_to": data["date_to"],
"move_target": data["move_target"],
"with_auto_sequence": data["with_auto_sequence"],
"account_ids_data": account_ids_data,
"partner_ids_data": partner_ids_data,
"currency_ids_data": currency_ids_data,
"move_ids_data": move_ids_data,
"tax_line_data": tax_line_ids_data,
"move_line_ids_taxes_data": move_line_ids_taxes_data,
"Journal_Ledgers": journal_ledgers_data,
"Moves": moves_data,
}
)
return res

View File

@ -167,7 +167,7 @@ class OpenItemsReport(models.AbstractModel):
"partner_name": partner.name or "",
"ref_label": ref_label,
"journal_id": move_line["journal_id"][0],
"move_name": move_line["move_id"][1],
"move_name": move_line["move_name"],
"entry_id": move_line["move_id"][0],
"currency_id": move_line["currency_id"][0]
if move_line["currency_id"]
@ -252,6 +252,7 @@ class OpenItemsReport(models.AbstractModel):
return new_open_items
def _get_report_values(self, docids, data):
res = super()._get_report_values(docids, data)
wizard_id = data["wizard_id"]
company = self.env["res.company"].browse(data["company_id"])
company_id = data["company_id"]
@ -291,24 +292,27 @@ class OpenItemsReport(models.AbstractModel):
partners_data,
accounts_data,
)
return {
"doc_ids": [wizard_id],
"doc_model": "open.items.report.wizard",
"docs": self.env["open.items.report.wizard"].browse(wizard_id),
"foreign_currency": data["foreign_currency"],
"show_partner_details": data["show_partner_details"],
"company_name": company.display_name,
"currency_name": company.currency_id.name,
"date_at": date_at_object.strftime("%d/%m/%Y"),
"hide_account_at_0": data["hide_account_at_0"],
"target_move": data["target_move"],
"journals_data": journals_data,
"partners_data": partners_data,
"accounts_data": accounts_data,
"total_amount": total_amount,
"Open_Items": open_items_move_lines_data,
"grouped_by": grouped_by,
}
res.update(
{
"doc_ids": [wizard_id],
"doc_model": "open.items.report.wizard",
"docs": self.env["open.items.report.wizard"].browse(wizard_id),
"foreign_currency": data["foreign_currency"],
"show_partner_details": data["show_partner_details"],
"company_name": company.display_name,
"currency_name": company.currency_id.name,
"date_at": date_at_object.strftime("%d/%m/%Y"),
"hide_account_at_0": data["hide_account_at_0"],
"target_move": data["target_move"],
"journals_data": journals_data,
"partners_data": partners_data,
"accounts_data": accounts_data,
"total_amount": total_amount,
"Open_Items": open_items_move_lines_data,
"grouped_by": grouped_by,
}
)
return res
def _get_ml_fields(self):
return self.COMMON_ML_FIELDS + [
@ -321,6 +325,7 @@ class OpenItemsReport(models.AbstractModel):
"amount_residual_currency",
"debit",
"amount_currency",
"move_name",
]
def get_analytic_domain(self, domain, analytic_account_ids, no_analytic):

View File

@ -469,12 +469,16 @@
res-model="account.move.line"
view-type="form"
>
<t t-out="line['ref_label']" />
<t
t-out="limit_text(line['ref_label'], 'label_text_limit')"
/>
</span>
</t>
<t t-else="">
<span>
<t t-out="line['ref_label']" />
<t
t-out="limit_text(line['ref_label'], 'label_text_limit')"
/>
</span>
</t>
</div>

View File

@ -267,7 +267,10 @@
/>
</div>
<div class="act_as_cell left" name="label">
<span t-if="move_line['label']" t-esc="move_line['label']" />
<span
t-if="move_line['label']"
t-esc="limit_text(move_line['label'], 'label_text_limit')"
/>
<span t-if="not move_line['label']">/</span>
</div>
<div class="act_as_cell left" name="taxes">

View File

@ -357,7 +357,7 @@
</t>
<!--## ref - label-->
<div class="act_as_cell left">
<span t-esc="line['ref_label']" />
<span t-esc="limit_text(line['ref_label'], 'label_text_limit')" />
</div>
<!--## date_due-->
<div class="act_as_cell left">

View File

@ -808,6 +808,7 @@ class TrialBalanceReport(models.AbstractModel):
return groups_data
def _get_report_values(self, docids, data):
res = super()._get_report_values(docids, data)
show_partner_details = data["show_partner_details"]
wizard_id = data["wizard_id"]
company = self.env["res.company"].browse(data["company_id"])
@ -902,28 +903,31 @@ class TrialBalanceReport(models.AbstractModel):
total_amount[account_id]["currency_name"] = accounts_data[
account_id
]["currency_name"]
return {
"doc_ids": [wizard_id],
"doc_model": "trial.balance.report.wizard",
"docs": self.env["trial.balance.report.wizard"].browse(wizard_id),
"foreign_currency": data["foreign_currency"],
"company_name": company.display_name,
"company_currency": company.currency_id,
"currency_name": company.currency_id.name,
"date_from": data["date_from"],
"date_to": data["date_to"],
"only_posted_moves": data["only_posted_moves"],
"hide_account_at_0": data["hide_account_at_0"],
"show_partner_details": data["show_partner_details"],
"limit_hierarchy_level": data["limit_hierarchy_level"],
"show_hierarchy": show_hierarchy,
"hide_parent_hierarchy_level": data["hide_parent_hierarchy_level"],
"trial_balance": trial_balance,
"trial_balance_grouped": trial_balance_grouped,
"total_amount": total_amount,
"total_amount_grouped": total_amount_grouped,
"accounts_data": accounts_data,
"partners_data": partners_data,
"show_hierarchy_level": show_hierarchy_level,
"grouped_by": grouped_by,
}
res.update(
{
"doc_ids": [wizard_id],
"doc_model": "trial.balance.report.wizard",
"docs": self.env["trial.balance.report.wizard"].browse(wizard_id),
"foreign_currency": data["foreign_currency"],
"company_name": company.display_name,
"company_currency": company.currency_id,
"currency_name": company.currency_id.name,
"date_from": data["date_from"],
"date_to": data["date_to"],
"only_posted_moves": data["only_posted_moves"],
"hide_account_at_0": data["hide_account_at_0"],
"show_partner_details": data["show_partner_details"],
"limit_hierarchy_level": data["limit_hierarchy_level"],
"show_hierarchy": show_hierarchy,
"hide_parent_hierarchy_level": data["hide_parent_hierarchy_level"],
"trial_balance": trial_balance,
"trial_balance_grouped": trial_balance_grouped,
"total_amount": total_amount,
"total_amount_grouped": total_amount_grouped,
"accounts_data": accounts_data,
"partners_data": partners_data,
"show_hierarchy_level": show_hierarchy_level,
"grouped_by": grouped_by,
}
)
return res

View File

@ -8,6 +8,7 @@ from odoo import api, models
class VATReport(models.AbstractModel):
_inherit = "report.account_financial_report.abstract_report"
_name = "report.account_financial_report.vat_report"
_description = "Vat Report Report"
@ -197,6 +198,7 @@ class VATReport(models.AbstractModel):
return vat_report_list
def _get_report_values(self, docids, data):
res = super()._get_report_values(docids, data)
wizard_id = data["wizard_id"]
company = self.env["res.company"].browse(data["company_id"])
company_id = data["company_id"]
@ -216,18 +218,21 @@ class VATReport(models.AbstractModel):
vat_report = self._get_vat_report_tag_data(
vat_report_data, tax_data, tax_detail
)
return {
"doc_ids": [wizard_id],
"doc_model": "open.items.report.wizard",
"docs": self.env["open.items.report.wizard"].browse(wizard_id),
"company_name": company.display_name,
"currency_name": company.currency_id.name,
"date_to": data["date_to"],
"date_from": data["date_from"],
"based_on": data["based_on"],
"tax_detail": data["tax_detail"],
"vat_report": vat_report,
}
res.update(
{
"doc_ids": [wizard_id],
"doc_model": "open.items.report.wizard",
"docs": self.env["open.items.report.wizard"].browse(wizard_id),
"company_name": company.display_name,
"currency_name": company.currency_id.name,
"date_to": data["date_to"],
"date_from": data["date_from"],
"based_on": data["based_on"],
"tax_detail": data["tax_detail"],
"vat_report": vat_report,
}
)
return res
def _get_ml_fields_vat_report(self):
return [

View File

@ -67,7 +67,7 @@ class TestAgedPartnerBalance(TransactionCase):
wizard = self.wizard_with_line_details
wizard.onchange_type_accounts_only()
data = wizard._prepare_report_aged_partner_balance()
data = wizard._prepare_report_data()
# Simulate web client behavior:
# default value is a datetime.date but web client sends back strings
@ -83,7 +83,7 @@ class TestAgedPartnerBalance(TransactionCase):
second_wizard = self.wizard_without_line_details
second_wizard.onchange_type_accounts_only()
data = second_wizard._prepare_report_aged_partner_balance()
data = second_wizard._prepare_report_data()
# Simulate web client behavior:
# default value is a datetime.date but web client sends back strings
@ -129,7 +129,7 @@ class TestAgedPartnerBalance(TransactionCase):
wizard.age_partner_config_id = self.account_age_report_config.id
wizard.onchange_type_accounts_only()
data = wizard._prepare_report_aged_partner_balance()
data = wizard._prepare_report_data()
# Simulate web client behavior:
# default value is a datetime.date but web client sends back strings
@ -147,7 +147,7 @@ class TestAgedPartnerBalance(TransactionCase):
second_wizard.age_partner_config_id = self.account_age_report_config.id
second_wizard.onchange_type_accounts_only()
data = second_wizard._prepare_report_aged_partner_balance()
data = second_wizard._prepare_report_data()
# Simulate web client behavior:
# default value is a datetime.date but web client sends back strings

View File

@ -128,7 +128,7 @@ class TestGeneralLedgerReport(AccountTestInvoicingCommon):
"centralize": centralize,
}
)
data = general_ledger._prepare_report_general_ledger()
data = general_ledger._prepare_report_data()
res_data = self.env[
"report.account_financial_report.general_ledger"
]._get_report_values(general_ledger, data)

View File

@ -177,7 +177,7 @@ class TestJournalReport(AccountTestInvoicingCommon):
"move_target": "all",
}
)
data = wiz._prepare_report_journal_ledger()
data = wiz._prepare_report_data()
res_data = self.JournalLedgerReport._get_report_values(wiz, data)
self.check_report_journal_debit_credit(res_data, 100, 100)
@ -186,7 +186,7 @@ class TestJournalReport(AccountTestInvoicingCommon):
res_data = self.JournalLedgerReport._get_report_values(wiz, data)
self.check_report_journal_debit_credit(res_data, 200, 200)
wiz.move_target = "posted"
data = wiz._prepare_report_journal_ledger()
data = wiz._prepare_report_data()
res_data = self.JournalLedgerReport._get_report_values(wiz, data)
self.check_report_journal_debit_credit(res_data, 0, 0)
@ -203,7 +203,7 @@ class TestJournalReport(AccountTestInvoicingCommon):
self.check_report_journal_debit_credit(res_data, 200, 200)
wiz.date_from = self.previous_fy_date_start
data = wiz._prepare_report_journal_ledger()
data = wiz._prepare_report_data()
res_data = self.JournalLedgerReport._get_report_values(wiz, data)
self.check_report_journal_debit_credit(res_data, 300, 300)
@ -238,7 +238,7 @@ class TestJournalReport(AccountTestInvoicingCommon):
"move_target": "all",
}
)
data = wiz._prepare_report_journal_ledger()
data = wiz._prepare_report_data()
res_data = self.JournalLedgerReport._get_report_values(wiz, data)
self.check_report_journal_debit_credit(res_data, 250, 250)
self.check_report_journal_debit_credit_taxes(res_data, 0, 300, 0, 50)
@ -276,7 +276,7 @@ class TestJournalReport(AccountTestInvoicingCommon):
"move_target": "all",
}
)
data = wiz._prepare_report_journal_ledger()
data = wiz._prepare_report_data()
res_data = self.JournalLedgerReport._get_report_values(wiz, data)
self.check_report_journal_debit_credit(res_data, 250, 250)

View File

@ -91,5 +91,5 @@ class TestOpenItems(AccountTestInvoicingCommon):
}
)
wizard.on_change_account_range()
res = wizard._prepare_report_open_items()
res = wizard._prepare_report_data()
self.assertEqual(res["grouped_by"], wizard.grouped_by)

View File

@ -199,7 +199,7 @@ class TestTrialBalanceReport(AccountTestInvoicingCommon):
"show_partner_details": with_partners,
}
)
data = trial_balance._prepare_report_trial_balance()
data = trial_balance._prepare_report_data()
res_data = self.env[
"report.account_financial_report.trial_balance"
]._get_report_values(trial_balance, data)
@ -554,7 +554,7 @@ class TestTrialBalanceReport(AccountTestInvoicingCommon):
"fy_start_date": self.fy_date_start,
}
)
data = trial_balance._prepare_report_trial_balance()
data = trial_balance._prepare_report_data()
res_data = self.env[
"report.account_financial_report.trial_balance"
]._get_report_values(trial_balance, data)
@ -607,7 +607,7 @@ class TestTrialBalanceReport(AccountTestInvoicingCommon):
"fy_start_date": self.fy_date_start,
}
)
data = trial_balance._prepare_report_trial_balance()
data = trial_balance._prepare_report_data()
res_data = self.env[
"report.account_financial_report.trial_balance"
]._get_report_values(trial_balance, data)
@ -661,7 +661,7 @@ class TestTrialBalanceReport(AccountTestInvoicingCommon):
"fy_start_date": self.fy_date_start,
}
)
data = trial_balance._prepare_report_trial_balance()
data = trial_balance._prepare_report_data()
res_data = self.env[
"report.account_financial_report.trial_balance"
]._get_report_values(trial_balance, data)

View File

@ -219,7 +219,7 @@ class TestVATReport(AccountTestInvoicingCommon):
"tax_detail": True,
}
)
data = vat_report._prepare_vat_report()
data = vat_report._prepare_report_data()
res_data = self.env[
"report.account_financial_report.vat_report"
]._get_report_values(vat_report, data)

View File

@ -34,18 +34,41 @@ class AbstractWizard(models.AbstractModel):
required=False,
string="Company",
)
label_text_limit = fields.Integer(default=40)
def button_export_html(self):
self.ensure_one()
self._set_default_wizard_values()
report_type = "qweb-html"
return self._export(report_type)
def button_export_pdf(self):
self.ensure_one()
self._set_default_wizard_values()
report_type = "qweb-pdf"
return self._export(report_type)
def button_export_xlsx(self):
self.ensure_one()
self._set_default_wizard_values()
report_type = "xlsx"
return self._export(report_type)
def _limit_text(self, value, limit_field="label_text_limit"):
limit = self[limit_field]
if value and limit and len(value) > limit:
value = value[:limit] + "..."
return value
def _prepare_report_data(self):
self.ensure_one()
return {"wizard_name": self._name, "wizard_id": self.id}
def _set_default_wizard_values(self):
self.env["ir.default"].set(
self._name,
"label_text_limit",
self.label_text_limit,
user_id=False,
company_id=True,
)

View File

@ -139,7 +139,7 @@ class AgedPartnerBalanceWizard(models.TransientModel):
def _print_report(self, report_type):
self.ensure_one()
data = self._prepare_report_aged_partner_balance()
data = self._prepare_report_data()
if report_type == "xlsx":
report_name = "a_f_r.report_aged_partner_balance_xlsx"
else:
@ -153,22 +153,24 @@ class AgedPartnerBalanceWizard(models.TransientModel):
.report_action(self, data=data)
)
def _prepare_report_aged_partner_balance(self):
self.ensure_one()
return {
"wizard_id": self.id,
"date_at": self.date_at,
"date_from": self.date_from or False,
"only_posted_moves": self.target_move == "posted",
"company_id": self.company_id.id,
"account_ids": self.account_ids.ids,
"partner_ids": self.partner_ids.ids,
"show_move_line_details": self.show_move_line_details,
"account_financial_report_lang": self.env.lang,
"age_partner_config_id": self.age_partner_config_id.id,
"analytic_account_ids": self.analytic_account_ids.ids or [],
"no_analytic": self.no_analytic,
}
def _prepare_report_data(self):
res = super()._prepare_report_data()
res.update(
{
"date_at": self.date_at,
"date_from": self.date_from or False,
"only_posted_moves": self.target_move == "posted",
"company_id": self.company_id.id,
"account_ids": self.account_ids.ids,
"partner_ids": self.partner_ids.ids,
"show_move_line_details": self.show_move_line_details,
"account_financial_report_lang": self.env.lang,
"age_partner_config_id": self.age_partner_config_id.id,
"analytic_account_ids": self.analytic_account_ids.ids or [],
"no_analytic": self.no_analytic,
}
)
return res
def _export(self, report_type):
"""Default export is PDF."""

View File

@ -272,7 +272,7 @@ class GeneralLedgerReportWizard(models.TransientModel):
def _print_report(self, report_type):
self.ensure_one()
data = self._prepare_report_general_ledger()
data = self._prepare_report_data()
if report_type == "xlsx":
report_name = "a_f_r.report_general_ledger_xlsx"
else:
@ -286,10 +286,6 @@ class GeneralLedgerReportWizard(models.TransientModel):
.report_action(self, data=data)
)
def _prepare_report_general_ledger(self):
self.ensure_one()
return {"wizard_id": self.id}
def _export(self, report_type):
"""Default export is PDF."""
return self._print_report(report_type)

View File

@ -102,6 +102,11 @@
context="{'skip_search_count': 1}"
/>
</page>
<page name="format" string="Format">
<group>
<field name="label_text_limit" />
</group>
</page>
</notebook>
</div>
<div

View File

@ -75,7 +75,7 @@ class JournalLedgerReportWizard(models.TransientModel):
def _print_report(self, report_type):
self.ensure_one()
data = self._prepare_report_journal_ledger()
data = self._prepare_report_data()
if report_type == "xlsx":
report_name = "a_f_r.report_journal_ledger_xlsx"
else:
@ -89,28 +89,30 @@ class JournalLedgerReportWizard(models.TransientModel):
.report_action(self, data=data)
)
def _prepare_report_journal_ledger(self):
self.ensure_one()
def _prepare_report_data(self):
res = super()._prepare_report_data()
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)]
)
return {
"wizard_id": self.id,
"date_from": self.date_from,
"date_to": self.date_to,
"move_target": self.move_target,
"foreign_currency": self.foreign_currency,
"company_id": self.company_id.id,
"journal_ids": journals.ids,
"sort_option": self.sort_option,
"group_option": self.group_option,
"with_account_name": self.with_account_name,
"account_financial_report_lang": self.env.lang,
"with_auto_sequence": self.with_auto_sequence,
}
res.update(
{
"date_from": self.date_from,
"date_to": self.date_to,
"move_target": self.move_target,
"foreign_currency": self.foreign_currency,
"company_id": self.company_id.id,
"journal_ids": journals.ids,
"sort_option": self.sort_option,
"group_option": self.group_option,
"with_account_name": self.with_account_name,
"account_financial_report_lang": self.env.lang,
"with_auto_sequence": self.with_auto_sequence,
}
)
return res
def _export(self, report_type):
"""Default export is PDF."""

View File

@ -32,6 +32,7 @@
<field name="foreign_currency" />
<field name="with_account_name" />
<field name="with_auto_sequence" />
<field name="label_text_limit" />
</group>
<group />
</group>

View File

@ -171,7 +171,7 @@ class OpenItemsReportWizard(models.TransientModel):
def _print_report(self, report_type):
self.ensure_one()
data = self._prepare_report_open_items()
data = self._prepare_report_data()
if report_type == "xlsx":
report_name = "a_f_r.report_open_items_xlsx"
else:
@ -185,25 +185,27 @@ class OpenItemsReportWizard(models.TransientModel):
.report_action(self, data=data)
)
def _prepare_report_open_items(self):
self.ensure_one()
return {
"wizard_id": self.id,
"date_at": fields.Date.to_string(self.date_at),
"date_from": self.date_from or False,
"only_posted_moves": self.target_move == "posted",
"hide_account_at_0": self.hide_account_at_0,
"foreign_currency": self.foreign_currency,
"show_partner_details": self.show_partner_details,
"company_id": self.company_id.id,
"target_move": self.target_move,
"account_ids": self.account_ids.ids,
"partner_ids": self.partner_ids.ids or [],
"analytic_account_ids": self.analytic_account_ids.ids or [],
"account_financial_report_lang": self.env.lang,
"grouped_by": self.grouped_by,
"no_analytic": self.no_analytic,
}
def _prepare_report_data(self):
res = super()._prepare_report_data()
res.update(
{
"date_at": fields.Date.to_string(self.date_at),
"date_from": self.date_from or False,
"only_posted_moves": self.target_move == "posted",
"hide_account_at_0": self.hide_account_at_0,
"foreign_currency": self.foreign_currency,
"show_partner_details": self.show_partner_details,
"company_id": self.company_id.id,
"target_move": self.target_move,
"account_ids": self.account_ids.ids,
"partner_ids": self.partner_ids.ids or [],
"analytic_account_ids": self.analytic_account_ids.ids or [],
"account_financial_report_lang": self.env.lang,
"grouped_by": self.grouped_by,
"no_analytic": self.no_analytic,
}
)
return res
def _export(self, report_type):
return self._print_report(report_type)

View File

@ -24,6 +24,7 @@
<field name="grouped_by" />
<field name="hide_account_at_0" />
<field name="foreign_currency" />
<field name="label_text_limit" />
</group>
</group>
<group name="partner_filter" col="1">

View File

@ -233,7 +233,7 @@ class TrialBalanceReportWizard(models.TransientModel):
def _print_report(self, report_type):
self.ensure_one()
data = self._prepare_report_trial_balance()
data = self._prepare_report_data()
if report_type == "xlsx":
report_name = "a_f_r.report_trial_balance_xlsx"
else:
@ -247,29 +247,31 @@ class TrialBalanceReportWizard(models.TransientModel):
.report_action(self, data=data)
)
def _prepare_report_trial_balance(self):
self.ensure_one()
return {
"wizard_id": self.id,
"date_from": self.date_from,
"date_to": self.date_to,
"only_posted_moves": self.target_move == "posted",
"hide_account_at_0": self.hide_account_at_0,
"foreign_currency": self.foreign_currency,
"company_id": self.company_id.id,
"account_ids": self.account_ids.ids or [],
"partner_ids": self.partner_ids.ids or [],
"journal_ids": self.journal_ids.ids or [],
"fy_start_date": self.fy_start_date,
"show_hierarchy": self.show_hierarchy,
"limit_hierarchy_level": self.limit_hierarchy_level,
"show_hierarchy_level": self.show_hierarchy_level,
"hide_parent_hierarchy_level": self.hide_parent_hierarchy_level,
"show_partner_details": self.show_partner_details,
"unaffected_earnings_account": self.unaffected_earnings_account.id,
"account_financial_report_lang": self.env.lang,
"grouped_by": self.grouped_by,
}
def _prepare_report_data(self):
res = super()._prepare_report_data()
res.update(
{
"date_from": self.date_from,
"date_to": self.date_to,
"only_posted_moves": self.target_move == "posted",
"hide_account_at_0": self.hide_account_at_0,
"foreign_currency": self.foreign_currency,
"company_id": self.company_id.id,
"account_ids": self.account_ids.ids or [],
"partner_ids": self.partner_ids.ids or [],
"journal_ids": self.journal_ids.ids or [],
"fy_start_date": self.fy_start_date,
"show_hierarchy": self.show_hierarchy,
"limit_hierarchy_level": self.limit_hierarchy_level,
"show_hierarchy_level": self.show_hierarchy_level,
"hide_parent_hierarchy_level": self.hide_parent_hierarchy_level,
"show_partner_details": self.show_partner_details,
"unaffected_earnings_account": self.unaffected_earnings_account.id,
"account_financial_report_lang": self.env.lang,
"grouped_by": self.grouped_by,
}
)
return res
def _export(self, report_type):
"""Default export is PDF."""

View File

@ -68,7 +68,7 @@ class VATReportWizard(models.TransientModel):
def _print_report(self, report_type):
self.ensure_one()
data = self._prepare_vat_report()
data = self._prepare_report_data()
if report_type == "xlsx":
report_name = "a_f_r.report_vat_report_xlsx"
else:
@ -82,18 +82,20 @@ class VATReportWizard(models.TransientModel):
.report_action(self, data=data)
)
def _prepare_vat_report(self):
self.ensure_one()
return {
"wizard_id": self.id,
"company_id": self.company_id.id,
"date_from": self.date_from,
"date_to": self.date_to,
"based_on": self.based_on,
"only_posted_moves": self.target_move == "posted",
"tax_detail": self.tax_detail,
"account_financial_report_lang": self.env.lang,
}
def _prepare_report_data(self):
res = super()._prepare_report_data()
res.update(
{
"company_id": self.company_id.id,
"date_from": self.date_from,
"date_to": self.date_to,
"based_on": self.based_on,
"only_posted_moves": self.target_move == "posted",
"tax_detail": self.tax_detail,
"account_financial_report_lang": self.env.lang,
}
)
return res
def _export(self, report_type):
"""Default export is PDF."""

View File

@ -50,5 +50,5 @@ class TestOpenItems(AccountTestInvoicingCommon):
}
)
wizard.on_change_account_range()
res = wizard._prepare_report_open_items()
res = wizard._prepare_report_data()
self.assertEqual(res["grouped_by"], wizard.grouped_by)