Skip to content

Commit 8d6082d

Browse files
[IMP] Add ecotax amounts in invoice report
1 parent b07e2b1 commit 8d6082d

File tree

7 files changed

+95
-2
lines changed

7 files changed

+95
-2
lines changed

account_ecotax/__manifest__.py

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"views/account_move_view.xml",
2626
"views/product_template_view.xml",
2727
"views/product_view.xml",
28+
"report/invoice.xml",
2829
],
2930
"installable": True,
3031
}

account_ecotax/models/account_move.py

+4
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,7 @@ def _get_tax_totals(
5959
)
6060
res["groups_by_subtotal"][_("Untaxed Amount")] = data
6161
return res
62+
63+
def _get_formatted_ecotax_amount(self):
64+
self.ensure_one()
65+
return formatLang(self.env, self.amount_ecotax, currency_obj=self.currency_id)

account_ecotax/report/invoice.xml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<odoo>
3+
<template
4+
id="report_invoice_document"
5+
inherit_id="account.report_invoice_document"
6+
priority="100"
7+
>
8+
<xpath expr="//th[@name='th_price_unit']" position="after">
9+
<th
10+
name="th_ecotax"
11+
t-if="o.amount_ecotax"
12+
t-attf-class="text-right {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}"
13+
>
14+
<span name="ecotax_line_label">Eco Part Unit</span>
15+
</th>
16+
</xpath>
17+
<xpath expr="//td[span[@t-field='line.discount']]" position="after">
18+
<td
19+
t-if="o.amount_ecotax"
20+
t-attf-class="text-center {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}"
21+
>
22+
<span
23+
class="text-nowrap"
24+
t-field="line.ecotax_amount_unit"
25+
/>
26+
</td>
27+
</xpath>
28+
</template>
29+
30+
<template
31+
id="document_tax_totals"
32+
inherit_id="account.document_tax_totals"
33+
priority="100"
34+
>
35+
<xpath expr="//t[@t-set='subtotal_to_show']" position="before">
36+
<tr t-if="o.amount_ecotax" name="ecotax_line">
37+
<td name="ecotax_label">Including Eco Part</td>
38+
<td class="text-end">
39+
<span
40+
t-esc="o._get_formatted_ecotax_amount()"
41+
/>
42+
</td>
43+
</tr>
44+
</xpath>
45+
</template>
46+
</odoo>

account_ecotax/views/account_move_view.xml

+6-2
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,14 @@
138138
<field name="name" widget="text" readonly="1" />
139139
<notebook>
140140
<page string="Ecotaxe lines" name="ecotax_line">
141-
<field name="ecotax_line_ids" nolabel="1" readonly="1">
141+
<field
142+
name="ecotax_line_ids"
143+
nolabel="1"
144+
attrs="{'readonly': [('parent_state', '!=', 'draft')]}"
145+
>
142146
<tree editable="bottom">
143147
<field name="classification_id" />
144-
<field name="force_amount_unit" readonly="1" />
148+
<field name="force_amount_unit" />
145149
<field name="amount_unit" />
146150
<field
147151
name="amount_total"

account_ecotax_tax/__manifest__.py

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
"data": [
1818
"views/account_ecotax_classification_view.xml",
1919
"views/account_tax_view.xml",
20+
"views/account_move_view.xml",
21+
"report/invoice.xml",
2022
],
2123
"installable": True,
2224
}

account_ecotax_tax/report/invoice.xml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<odoo>
3+
<template
4+
id="report_invoice_document"
5+
inherit_id="account.report_invoice_document"
6+
priority="150"
7+
>
8+
<xpath expr="//t[@t-set='taxes']" position="replace">
9+
<t
10+
t-set="taxes"
11+
t-value="', '.join([(tax.description or tax.name) for tax in line.tax_ids.filtered(lambda t: not t.is_ecotax)])"
12+
/>
13+
</xpath>
14+
</template>
15+
16+
<template
17+
id="document_tax_totals"
18+
inherit_id="account.document_tax_totals"
19+
priority="150"
20+
>
21+
<xpath expr="//tr[@name='ecotax_line']" position="replace">
22+
</xpath>
23+
</template>
24+
</odoo>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<odoo>
3+
<record id="view_move_line_ecotax_form" model="ir.ui.view">
4+
<field name="model">account.move.line</field>
5+
<field name="inherit_id" ref="account_ecotax.view_move_line_ecotax_form" />
6+
<field name="arch" type="xml">
7+
<field name="ecotax_line_ids" position="attributes">
8+
<attribute name="readonly">1</attribute>
9+
</field>
10+
</field>
11+
</record>
12+
</odoo>

0 commit comments

Comments
 (0)