Skip to content

Commit 97ada3c

Browse files
committed
[IMP] account_financial_report: Add grouping by analytical account in Trial balance
TT48969
1 parent 37e67e1 commit 97ada3c

File tree

5 files changed

+419
-77
lines changed

5 files changed

+419
-77
lines changed

account_financial_report/report/templates/trial_balance.xml

Lines changed: 166 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -36,43 +36,94 @@
3636
<t t-call="account_financial_report.report_trial_balance_filters" />
3737
<div class="act_as_table list_table" style="margin-top: 10px;" />
3838
<!-- Display account lines -->
39+
<t t-set="aml_domain_extra" t-value="[]" />
3940
<t t-if="not show_partner_details">
40-
<div class="act_as_table data_table" style="width: 100%;">
41-
<!-- Display account header -->
42-
<t
43-
t-call="account_financial_report.report_trial_balance_lines_header"
44-
/>
45-
<!-- Display each lines -->
46-
<t t-foreach="trial_balance" t-as="balance">
47-
<!-- Adapt -->
48-
<t t-set="style" t-value="'font-size:12px;'" />
49-
<!-- Different style for account group -->
50-
<t t-if="show_hierarchy">
51-
<t
52-
t-if="balance['type'] == 'group_type'"
53-
>
41+
<t t-if="trial_balance_grouped">
42+
<t t-foreach="trial_balance_grouped" t-as="grouped_item">
43+
<div class="act_as_table data_table" style="width: 100%;">
44+
<div class="act_as_thead">
45+
<div class="act_as_row labels">
46+
<div class="act_as_cell" style="width: 100%;">
47+
<t t-esc="grouped_item['name']" />
48+
</div>
49+
</div>
50+
</div>
51+
</div>
52+
<t
53+
t-set="aml_domain_extra"
54+
t-if="grouped_item['id'] > 0"
55+
t-value="[('analytic_account_id', '=', grouped_item['id'])]"
56+
/>
57+
<t
58+
t-set="aml_domain_extra"
59+
t-else=""
60+
t-value="[('analytic_account_id', '=', False)]"
61+
/>
62+
<div class="act_as_table data_table" style="width: 100%;">
63+
<t
64+
t-call="account_financial_report.report_trial_balance_lines_header"
65+
/>
66+
<!-- Display each lines -->
67+
<t t-foreach="grouped_item['account_data']" t-as="balance">
68+
<!-- Adapt -->
69+
<t t-set="style" t-value="'font-size:12px;'" />
5470
<t
55-
t-set="style"
56-
t-value="style + 'font-weight: bold; color: blue;'"
71+
t-call="account_financial_report.report_trial_balance_line"
5772
/>
5873
</t>
59-
</t>
60-
<t t-if="show_hierarchy and limit_hierarchy_level">
61-
<t
62-
t-if="show_hierarchy_level > balance['level'] and (not hide_parent_hierarchy_level or (show_hierarchy_level - 1) == balance['level'])"
63-
>
74+
</div>
75+
<!-- Display footer with totals !-->
76+
<t t-set="balance" t-value="grouped_item" />
77+
<t
78+
t-call="account_financial_report.report_trial_balance_account_footer"
79+
/>
80+
</t>
81+
<!-- TOTAL !-->
82+
<t t-if="grouped_by">
83+
<t t-set="balance" t-value="total_amount_grouped" />
84+
<t
85+
t-call="account_financial_report.report_trial_balance_account_footer"
86+
/>
87+
</t>
88+
</t>
89+
<t t-else="">
90+
<div class="act_as_table data_table" style="width: 100%;">
91+
<!-- Display account header -->
92+
<t
93+
t-call="account_financial_report.report_trial_balance_lines_header"
94+
/>
95+
<!-- Display each lines -->
96+
<t t-foreach="trial_balance" t-as="balance">
97+
<!-- Adapt -->
98+
<t t-set="style" t-value="'font-size:12px;'" />
99+
<!-- Different style for account group -->
100+
<t t-if="show_hierarchy">
101+
<t
102+
t-if="balance['type'] == 'group_type'"
103+
>
104+
<t
105+
t-set="style"
106+
t-value="style + 'font-weight: bold; color: blue;'"
107+
/>
108+
</t>
109+
</t>
110+
<t t-if="show_hierarchy and limit_hierarchy_level">
111+
<t
112+
t-if="show_hierarchy_level > balance['level'] and (not hide_parent_hierarchy_level or (show_hierarchy_level - 1) == balance['level'])"
113+
>
114+
<t
115+
t-call="account_financial_report.report_trial_balance_line"
116+
/>
117+
</t>
118+
</t>
119+
<t t-else="">
64120
<t
65121
t-call="account_financial_report.report_trial_balance_line"
66122
/>
67123
</t>
68124
</t>
69-
<t t-else="">
70-
<t
71-
t-call="account_financial_report.report_trial_balance_line"
72-
/>
73-
</t>
74-
</t>
75-
</div>
125+
</div>
126+
</t>
76127
</t>
77128
<!-- Display partner lines -->
78129
<t t-if="show_partner_details">
@@ -279,7 +330,7 @@
279330
('date', '&lt;', date_from)]"
280331
/>
281332
<span
282-
t-att-domain="domain+aml_domain_common"
333+
t-att-domain="domain+aml_domain_common+aml_domain_extra"
283334
res-model="account.move.line"
284335
>
285336
<t
@@ -335,7 +386,7 @@
335386
('debit', '&lt;&gt;', 0)]"
336387
/>
337388
<span
338-
t-att-domain="domain+aml_domain_common"
389+
t-att-domain="domain+aml_domain_common+aml_domain_extra"
339390
res-model="account.move.line"
340391
>
341392
<t
@@ -395,7 +446,7 @@
395446
('credit', '&lt;&gt;', 0)]"
396447
/>
397448
<span
398-
t-att-domain="domain+aml_domain_common"
449+
t-att-domain="domain+aml_domain_common+aml_domain_extra"
399450
res-model="account.move.line"
400451
>
401452
<t
@@ -455,7 +506,7 @@
455506
('balance', '&lt;&gt;', 0)]"
456507
/>
457508
<span
458-
t-att-domain="domain+aml_domain_common"
509+
t-att-domain="domain+aml_domain_common+aml_domain_extra"
459510
res-model="account.move.line"
460511
>
461512
<t
@@ -512,7 +563,7 @@
512563
('date', '&lt;=', date_to)]"
513564
/>
514565
<span
515-
t-att-domain="domain+aml_domain_common"
566+
t-att-domain="domain+aml_domain_common+aml_domain_extra"
516567
res-model="account.move.line"
517568
>
518569
<t
@@ -570,7 +621,7 @@
570621
t-value="[('account_id', '=', balance['id'])]"
571622
/>
572623
<span
573-
t-att-domain="domain+aml_domain_common"
624+
t-att-domain="domain+aml_domain_common+aml_domain_extra"
574625
res-model="account.move.line"
575626
>
576627
<t
@@ -629,7 +680,7 @@
629680
t-value="[('account_id', '=', balance['id'])]"
630681
/>
631682
<span
632-
t-att-domain="domain+aml_domain_common"
683+
t-att-domain="domain+aml_domain_common+aml_domain_extra"
633684
res-model="account.move.line"
634685
>
635686
<t
@@ -835,44 +886,101 @@
835886
<div class="act_as_row labels" style="font-weight: bold;">
836887
<!--## date-->
837888
<div class="act_as_cell first_column" style="width: 33%;">
838-
<span t-out="accounts_data[account_id]['code']" />
839-
-
840-
<span t-out="accounts_data[account_id]['name']" />
889+
<t
890+
t-if="grouped_by and balance['type'] in ('analytic_account_type', 'total')"
891+
>
892+
<span t-out="balance['name']" />
893+
</t>
894+
<t t-else="">
895+
<span t-out="accounts_data[account_id]['code']" />
896+
-
897+
<span t-out="accounts_data[account_id]['name']" />
898+
</t>
841899
</div>
842900
<!--## Initial Balance-->
843901
<div class="act_as_cell amount" style="width: 9%;">
844-
<span
845-
t-out="total_amount[account_id]['initial_balance']"
846-
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
847-
/>
902+
<t
903+
t-if="grouped_by and balance['type'] in ('analytic_account_type', 'total')"
904+
>
905+
<span
906+
t-out="balance['initial_balance']"
907+
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
908+
/>
909+
</t>
910+
<t t-else="">
911+
<span
912+
t-out="total_amount[account_id]['initial_balance']"
913+
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
914+
/>
915+
</t>
848916
</div>
849917
<!--## Debit-->
850918
<div class="act_as_cell amount" style="width: 9%;">
851-
<span
852-
t-out="total_amount[account_id]['debit']"
853-
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
854-
/>
919+
<t
920+
t-if="grouped_by and balance['type'] in ('analytic_account_type', 'total')"
921+
>
922+
<span
923+
t-out="balance['debit']"
924+
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
925+
/>
926+
</t>
927+
<t t-else="">
928+
<span
929+
t-out="total_amount[account_id]['debit']"
930+
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
931+
/>
932+
</t>
855933
</div>
856934
<!--## Credit-->
857935
<div class="act_as_cell amount" style="width: 9%;">
858-
<span
859-
t-out="total_amount[account_id]['credit']"
860-
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
861-
/>
936+
<t
937+
t-if="grouped_by and balance['type'] in ('analytic_account_type', 'total')"
938+
>
939+
<span
940+
t-out="balance['credit']"
941+
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
942+
/>
943+
</t>
944+
<t t-else="">
945+
<span
946+
t-out="total_amount[account_id]['credit']"
947+
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
948+
/>
949+
</t>
862950
</div>
863951
<!--## Period balance-->
864952
<div class="act_as_cell amount" style="width: 9%;">
865-
<span
866-
t-out="total_amount[account_id]['balance']"
867-
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
868-
/>
953+
<t
954+
t-if="grouped_by and balance['type'] in ('analytic_account_type', 'total')"
955+
>
956+
<span
957+
t-out="balance['balance']"
958+
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
959+
/>
960+
</t>
961+
<t t-else="">
962+
<span
963+
t-out="total_amount[account_id]['balance']"
964+
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
965+
/>
966+
</t>
869967
</div>
870968
<!--## Ending balance-->
871969
<div class="act_as_cell amount" style="width: 9%;">
872-
<span
873-
t-out="total_amount[account_id]['ending_balance']"
874-
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
875-
/>
970+
<t
971+
t-if="grouped_by and balance['type'] in ('analytic_account_type', 'total')"
972+
>
973+
<span
974+
t-out="balance['ending_balance']"
975+
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
976+
/>
977+
</t>
978+
<t t-else="">
979+
<span
980+
t-out="total_amount[account_id]['ending_balance']"
981+
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
982+
/>
983+
</t>
876984
</div>
877985
<t t-if="foreign_currency">
878986
<!--## amount_total_due_currency-->

0 commit comments

Comments
 (0)