Skip to content

Commit

Permalink
[IMP] Add ecotax amounts in invoice report
Browse files Browse the repository at this point in the history
  • Loading branch information
florian-dacosta committed Dec 15, 2024
1 parent bf2dd62 commit 0c6d651
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 4 deletions.
1 change: 1 addition & 0 deletions account_ecotax/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"views/account_move_view.xml",
"views/product_template_view.xml",
"views/product_view.xml",
"report/invoice.xml",
],
"installable": True,
}
4 changes: 4 additions & 0 deletions account_ecotax/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,7 @@ def _get_tax_totals(
)
res["groups_by_subtotal"][_("Untaxed Amount")] = data
return res

Check warning on line 61 in account_ecotax/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

account_ecotax/models/account_move.py#L60-L61

Added lines #L60 - L61 were not covered by tests

def _get_formatted_ecotax_amount(self):
self.ensure_one()
return formatLang(self.env, self.amount_ecotax, currency_obj=self.currency_id)

Check warning on line 65 in account_ecotax/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

account_ecotax/models/account_move.py#L64-L65

Added lines #L64 - L65 were not covered by tests
49 changes: 49 additions & 0 deletions account_ecotax/report/invoice.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template
id="report_invoice_document"
inherit_id="account.report_invoice_document"
priority="100"
>
<xpath expr="//th[@name='th_price_unit']" position="after">
<th
name="th_ecotax"
t-if="o.amount_ecotax"
t-attf-class="text-right {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}"
>
<span name="ecotax_line_label">Eco Part Unit</span>
</th>
</xpath>
<xpath expr="//td[span[@t-field='line.discount']]" position="after">
<td
t-if="o.amount_ecotax"
t-attf-class="text-center {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}"
>
<span
class="text-nowrap"
t-field="line.ecotax_amount_unit"
/>
</td>
</xpath>
</template>

<template
id="document_tax_totals"
inherit_id="account.document_tax_totals"
priority="100"
>
<xpath expr="//t[@t-set='subtotal_to_show']" position="before">
<tr
t-if="o._name == 'account.move' and o.amount_ecotax"
name="ecotax_line"
>
<td name="ecotax_label">Including Eco Part</td>
<td class="text-end">
<span
t-esc="o._get_formatted_ecotax_amount()"
/>
</td>
</tr>
</xpath>
</template>
</odoo>
8 changes: 6 additions & 2 deletions account_ecotax/views/account_move_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,14 @@
<field name="name" widget="text" readonly="1" />
<notebook>
<page string="Ecotaxe lines" name="ecotax_line">
<field name="ecotax_line_ids" nolabel="1" readonly="1">
<field
name="ecotax_line_ids"
nolabel="1"
attrs="{'readonly': [('parent_state', '!=', 'draft')]}"
>
<tree editable="bottom">
<field name="classification_id" />
<field name="force_amount_unit" readonly="1" />
<field name="force_amount_unit" />
<field name="amount_unit" />
<field
name="amount_total"
Expand Down
2 changes: 1 addition & 1 deletion account_ecotax_tax/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ The advantages compared to the base account_ecotax module is that it allows to :
- Manage ecotax amount as included or excluded from the price of the product
- Isolate the amount of the ecotax in a specific accounting account (set on the tax)

Then the ecotax amounts are not considered as turnover, which could be good not depending on your country's legistlation or accountant preferences.
Then the ecotax amounts are not considered as turnover, which could be good or not depending on your country's legislation or accountant preferences.

**Table of contents**

Expand Down
2 changes: 2 additions & 0 deletions account_ecotax_tax/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
"data": [
"views/account_ecotax_classification_view.xml",
"views/account_tax_view.xml",
"views/account_move_view.xml",
"report/invoice.xml",
],
"installable": True,
}
24 changes: 24 additions & 0 deletions account_ecotax_tax/report/invoice.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template
id="report_invoice_document"
inherit_id="account.report_invoice_document"
priority="150"
>
<xpath expr="//t[@t-set='taxes']" position="replace">
<t
t-set="taxes"
t-value="', '.join([(tax.description or tax.name) for tax in line.tax_ids.filtered(lambda t: not t.is_ecotax)])"
/>
</xpath>
</template>

<template
id="document_tax_totals"
inherit_id="account.document_tax_totals"
priority="150"
>
<xpath expr="//tr[@name='ecotax_line']" position="replace">
</xpath>
</template>
</odoo>
2 changes: 1 addition & 1 deletion account_ecotax_tax/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ <h1 class="title">Ecotax Management (with Odoo tax)</h1>
The advantages compared to the base account_ecotax module is that it allows to :
- Manage ecotax amount as included or excluded from the price of the product
- Isolate the amount of the ecotax in a specific accounting account (set on the tax)</p>
<p>Then the ecotax amounts are not considered as turnover, which could be good not depending on your country’s legistlation or accountant preferences.</p>
<p>Then the ecotax amounts are not considered as turnover, which could be good or not depending on your country’s legislation or accountant preferences.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
Expand Down
12 changes: 12 additions & 0 deletions account_ecotax_tax/views/account_move_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="view_move_line_ecotax_form" model="ir.ui.view">
<field name="model">account.move.line</field>
<field name="inherit_id" ref="account_ecotax.view_move_line_ecotax_form" />
<field name="arch" type="xml">
<field name="ecotax_line_ids" position="attributes">
<attribute name="readonly">1</attribute>
</field>
</field>
</record>
</odoo>

0 comments on commit 0c6d651

Please sign in to comment.