[FIX] account_financial_report: Print report with details

pull/868/head
SimoRubi 2021-08-23 17:01:52 +02:00 committed by Jasmin Solanki
parent a45fccdb08
commit adc26fba3a
4 changed files with 64 additions and 29 deletions

View File

@ -218,9 +218,8 @@ class AgedPartnerBalanceReport(models.AbstractModel):
"ref", "ref",
"reconciled", "reconciled",
] ]
move_lines = self.env["account.move.line"].search_read( line_model = self.env["account.move.line"]
domain=domain, fields=ml_fields move_lines = line_model.search_read(domain=domain, fields=ml_fields)
)
journals_ids = set() journals_ids = set()
partners_ids = set() partners_ids = set()
partners_data = {} partners_data = {}
@ -288,6 +287,7 @@ class AgedPartnerBalanceReport(models.AbstractModel):
ref_label = move_line["ref"] + str(" - ") + move_line["name"] ref_label = move_line["ref"] + str(" - ") + move_line["name"]
move_line_data.update( move_line_data.update(
{ {
"line_rec": line_model.browse(move_line["id"]),
"date": move_line["date"], "date": move_line["date"],
"entry": move_line["move_id"][1], "entry": move_line["move_id"][1],
"jnl_id": move_line["journal_id"][0], "jnl_id": move_line["journal_id"][0],

View File

@ -249,7 +249,7 @@
<!--## date--> <!--## date-->
<div class="act_as_cell left"> <div class="act_as_cell left">
<span <span
t-att-res-id="line.move_line_id.id" t-att-res-id="line['line_rec'].id"
res-model="account.move.line" res-model="account.move.line"
view-type="form" view-type="form"
> >
@ -260,7 +260,7 @@
<!--## move--> <!--## move-->
<div class="act_as_cell left"> <div class="act_as_cell left">
<span <span
t-att-res-id="line.move_line_id.move_id.id" t-att-res-id="line['line_rec'].move_id.id"
res-model="account.move" res-model="account.move"
view-type="form" view-type="form"
> >
@ -270,7 +270,7 @@
<!--## journal--> <!--## journal-->
<div class="act_as_cell left"> <div class="act_as_cell left">
<span <span
t-att-res-id="line.move_line_id.move_id.journal_id.id" t-att-res-id="line['line_rec'].move_id.journal_id.id"
res-model="account.journal" res-model="account.journal"
view-type="form" view-type="form"
> >
@ -280,7 +280,7 @@
<!--## account code--> <!--## account code-->
<div class="act_as_cell left"> <div class="act_as_cell left">
<span <span
t-att-res-id="line.move_line_id.account_id.id" t-att-res-id="line['line_rec'].account_id.id"
res-model="account.account" res-model="account.account"
view-type="form" view-type="form"
> >
@ -290,7 +290,7 @@
<!--## partner--> <!--## partner-->
<div class="act_as_cell left"> <div class="act_as_cell left">
<span <span
t-att-res-id="line.move_line_id.partner_id.id" t-att-res-id="line['line_rec'].partner_id.id"
res-model="res.partner" res-model="res.partner"
view-type="form" view-type="form"
> >
@ -300,7 +300,7 @@
<!--## ref - label--> <!--## ref - label-->
<div class="act_as_cell left"> <div class="act_as_cell left">
<span <span
t-att-res-id="line.move_line_id.id" t-att-res-id="line['line_rec'].id"
res-model="account.move.line" res-model="account.move.line"
view-type="form" view-type="form"
> >
@ -310,7 +310,7 @@
<!--## date_due--> <!--## date_due-->
<div class="act_as_cell left"> <div class="act_as_cell left">
<span <span
t-att-res-id="line.move_line_id.id" t-att-res-id="line['line_rec'].id"
res-model="account.move.line" res-model="account.move.line"
view-type="form" view-type="form"
> >
@ -324,7 +324,7 @@
<!--## amount_residual--> <!--## amount_residual-->
<div class="act_as_cell amount"> <div class="act_as_cell amount">
<span <span
domain="[('id', 'in', (line.move_line_id | line.move_line_id.matched_debit_ids.mapped('debit_move_id') | line.move_line_id.matched_credit_ids.mapped('credit_move_id')).ids)]" domain="[('id', 'in', (line['line_rec'] | line['line_rec'].matched_debit_ids.mapped('debit_move_id') | line['line_rec'].matched_credit_ids.mapped('credit_move_id')).ids)]"
res-model="account.move.line" res-model="account.move.line"
> >
<t <t
@ -335,15 +335,15 @@
</div> </div>
<!--## current--> <!--## current-->
<div class="act_as_cell amount"> <div class="act_as_cell amount">
<t t-if="line.current == 0"> <t t-if="line['current'] == 0">
<span <span
t-field="line.current" t-esc="line['current']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/> />
</t> </t>
<t t-else=""> <t t-else="">
<span <span
domain="[('id', 'in', (line.move_line_id | line.move_line_id.matched_debit_ids.mapped('debit_move_id') | line.move_line_id.matched_credit_ids.mapped('credit_move_id')).ids)]" domain="[('id', 'in', (line['line_rec'] | line['line_rec'].matched_debit_ids.mapped('debit_move_id') | line['line_rec'].matched_credit_ids.mapped('credit_move_id')).ids)]"
res-model="account.move.line" res-model="account.move.line"
> >
<t <t
@ -355,15 +355,15 @@
</div> </div>
<!--## age_30_days--> <!--## age_30_days-->
<div class="act_as_cell amount"> <div class="act_as_cell amount">
<t t-if="line.age_30_days == 0"> <t t-if="line['30_days'] == 0">
<span <span
t-field="line.age_30_days" t-esc="line['30_days']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/> />
</t> </t>
<t t-else=""> <t t-else="">
<span <span
domain="[('id', 'in', (line.move_line_id | line.move_line_id.matched_debit_ids.mapped('debit_move_id') | line.move_line_id.matched_credit_ids.mapped('credit_move_id')).ids)]" domain="[('id', 'in', (line['line_rec'] | line['line_rec'].matched_debit_ids.mapped('debit_move_id') | line['line_rec'].matched_credit_ids.mapped('credit_move_id')).ids)]"
res-model="account.move.line" res-model="account.move.line"
> >
<t <t
@ -375,15 +375,15 @@
</div> </div>
<!--## age_60_days--> <!--## age_60_days-->
<div class="act_as_cell amount"> <div class="act_as_cell amount">
<t t-if="line.age_60_days == 0"> <t t-if="line['60_days'] == 0">
<span <span
t-field="line.age_60_days" t-esc="line['60_days']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/> />
</t> </t>
<t t-else=""> <t t-else="">
<span <span
domain="[('id', 'in', (line.move_line_id | line.move_line_id.matched_debit_ids.mapped('debit_move_id') | line.move_line_id.matched_credit_ids.mapped('credit_move_id')).ids)]" domain="[('id', 'in', (line['line_rec'] | line['line_rec'].matched_debit_ids.mapped('debit_move_id') | line['line_rec'].matched_credit_ids.mapped('credit_move_id')).ids)]"
res-model="account.move.line" res-model="account.move.line"
> >
<t <t
@ -395,15 +395,15 @@
</div> </div>
<!--## age_90_days--> <!--## age_90_days-->
<div class="act_as_cell amount"> <div class="act_as_cell amount">
<t t-if="line.age_90_days == 0"> <t t-if="line['90_days'] == 0">
<span <span
t-field="line.age_90_days" t-esc="line['90_days']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/> />
</t> </t>
<t t-else=""> <t t-else="">
<span <span
domain="[('id', 'in', (line.move_line_id | line.move_line_id.matched_debit_ids.mapped('debit_move_id') | line.move_line_id.matched_credit_ids.mapped('credit_move_id')).ids)]" domain="[('id', 'in', (line['line_rec'] | line['line_rec'].matched_debit_ids.mapped('debit_move_id') | line['line_rec'].matched_credit_ids.mapped('credit_move_id')).ids)]"
res-model="account.move.line" res-model="account.move.line"
> >
<t <t
@ -415,15 +415,15 @@
</div> </div>
<!--## age_120_days--> <!--## age_120_days-->
<div class="act_as_cell amount"> <div class="act_as_cell amount">
<t t-if="line.age_120_days == 0"> <t t-if="line['120_days'] == 0">
<span <span
t-field="line.age_120_days" t-esc="line['120_days']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/> />
</t> </t>
<t t-else=""> <t t-else="">
<span <span
domain="[('id', 'in', (line.move_line_id | line.move_line_id.matched_debit_ids.mapped('debit_move_id') | line.move_line_id.matched_credit_ids.mapped('credit_move_id')).ids)]" domain="[('id', 'in', (line['line_rec'] | line['line_rec'].matched_debit_ids.mapped('debit_move_id') | line['line_rec'].matched_credit_ids.mapped('credit_move_id')).ids)]"
res-model="account.move.line" res-model="account.move.line"
> >
<t <t
@ -435,15 +435,15 @@
</div> </div>
<!--## older--> <!--## older-->
<div class="act_as_cell amount"> <div class="act_as_cell amount">
<t t-if="line.older == 0"> <t t-if="line['older'] == 0">
<span <span
t-field="line.older" t-esc="line['older']"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/> />
</t> </t>
<t t-else=""> <t t-else="">
<span <span
domain="[('id', 'in', (line.move_line_id | line.move_line_id.matched_debit_ids.mapped('debit_move_id') | line.move_line_id.matched_credit_ids.mapped('credit_move_id')).ids)]" domain="[('id', 'in', (line['line_rec'] | line['line_rec'].matched_debit_ids.mapped('debit_move_id') | line['line_rec'].matched_credit_ids.mapped('credit_move_id')).ids)]"
res-model="account.move.line" res-model="account.move.line"
> >
<t <t

View File

@ -1,6 +1,7 @@
# © 2016 Julien Coux (Camptocamp) # © 2016 Julien Coux (Camptocamp)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).- # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).-
from . import test_aged_partner_balance
from . import test_general_ledger from . import test_general_ledger
from . import test_journal_ledger from . import test_journal_ledger
from . import test_open_items from . import test_open_items

View File

@ -0,0 +1,34 @@
# Copyright 2021 Simone Rubino - Agile Business Group
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo.tests import TransactionCase
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT, test_reports
class TestAgedPartnerBalance(TransactionCase):
def setUp(self):
super().setUp()
self.wizard_model = self.env["aged.partner.balance.report.wizard"]
def test_report(self):
"""Check that report is produced correctly."""
wizard = self.wizard_model.create(
{
"show_move_line_details": True,
"receivable_accounts_only": True,
}
)
wizard.onchange_type_accounts_only()
data = wizard._prepare_report_aged_partner_balance()
# Simulate web client behavior:
# default value is a datetime.date but web client sends back strings
data.update({"date_at": data["date_at"].strftime(DEFAULT_SERVER_DATE_FORMAT)})
result = test_reports.try_report(
self.env.cr,
self.env.uid,
"account_financial_report.aged_partner_balance",
wizard.ids,
data=data,
)
self.assertTrue(result)