Skip to content

Commit 47cde9a

Browse files
[REF] Split account_ecotax_sale into account_ecotax_sale and account_ecotax_sale_tax
1 parent 75b16d2 commit 47cde9a

File tree

22 files changed

+745
-316
lines changed

22 files changed

+745
-316
lines changed

account_ecotax_sale/README.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ sale Ecotax Management
2828

2929
|badge1| |badge2| |badge3| |badge4| |badge5|
3030

31-
This module is an extension of the module *l10n_fr_ecotax* for sale orders. Please refer to the README of the module *l10n_fr_ecotax* for more info about ecotax management.
31+
This module is an extension of the module *l10n_fr_ecotax* for sale orders. Please refer to the README of the module *account_ecotax* for more info about ecotax management.
3232

3333
**Table of contents**
3434

@@ -57,6 +57,8 @@ Contributors
5757
~~~~~~~~~~~~
5858

5959
* Mourad EL HADJ MIMOUNE <[email protected]>
60+
* Florian DA COSTA <[email protected]>
61+
6062

6163
Maintainers
6264
~~~~~~~~~~~
@@ -71,6 +73,17 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
7173
mission is to support the collaborative development of Odoo features and
7274
promote its widespread use.
7375

76+
.. |maintainer-mourad-ehm| image:: https://github.com/mourad-ehm.png?size=40px
77+
:target: https://github.com/mourad-ehm
78+
:alt: mourad-ehm
79+
.. |maintainer-florian-dacosta| image:: https://github.com/florian-dacosta.png?size=40px
80+
:target: https://github.com/florian-dacosta
81+
:alt: florian-dacosta
82+
83+
Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:
84+
85+
|maintainer-mourad-ehm| |maintainer-florian-dacosta|
86+
7487
This module is part of the `OCA/account-fiscal-rule <https://github.com/OCA/account-fiscal-rule/tree/16.0/account_ecotax_sale>`_ project on GitHub.
7588

7689
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

account_ecotax_sale/__manifest__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"name": "sale Ecotax Management",
66
"summary": "Sale Ecotaxe",
77
"version": "16.0.2.0.0",
8+
"maintainers": ["mourad-ehm", "florian-dacosta"],
89
"author": "Akretion,Odoo Community Association (OCA)",
910
"website": "https://github.com/OCA/account-fiscal-rule",
1011
"category": "Localization/Account Taxes",

account_ecotax_sale/models/sale_order_line.py

Lines changed: 12 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -25,58 +25,28 @@ class SaleOrderLine(models.Model):
2525
compute="_compute_ecotax",
2626
)
2727

28+
def _get_ecotax_amounts(self):
29+
self.ensure_one()
30+
unit = sum(self.ecotax_line_ids.mapped("amount_unit"))
31+
subtotal_ecotax = sum(self.ecotax_line_ids.mapped("amount_total"))
32+
return unit, subtotal_ecotax
33+
2834
@api.depends(
2935
"currency_id",
30-
"tax_id",
31-
"product_uom_qty",
32-
"product_id",
36+
"ecotax_line_ids.amount_unit",
37+
"ecotax_line_ids.amount_total",
3338
)
3439
def _compute_ecotax(self):
3540
for line in self:
36-
ecotax_ids = line.tax_id.filtered(lambda tax: tax.is_ecotax)
37-
if (line.display_type and line.display_type != "product") or not ecotax_ids:
38-
continue
39-
amount_currency = line.price_unit * (1 - line.discount / 100)
40-
quantity = line.product_uom_qty
41-
compute_all_currency = ecotax_ids.compute_all(
42-
amount_currency,
43-
currency=line.currency_id,
44-
quantity=quantity,
45-
product=line.product_id,
46-
partner=line.order_id.partner_shipping_id,
47-
)
48-
subtotal_ecotax = 0.0
49-
for tax in compute_all_currency["taxes"]:
50-
subtotal_ecotax += tax["amount"]
51-
52-
unit = quantity and subtotal_ecotax / quantity or subtotal_ecotax
53-
line.ecotax_amount_unit = unit
54-
line.subtotal_ecotax = subtotal_ecotax
55-
56-
@api.depends("product_id", "company_id")
57-
def _compute_tax_id(self):
58-
super()._compute_tax_id()
59-
for line in self:
60-
line.tax_id |= line._get_computed_ecotaxes()
61-
62-
def _get_computed_ecotaxes(self):
63-
self.ensure_one()
64-
sale_ecotaxes = self.product_id.all_ecotax_line_product_ids.mapped(
65-
"classification_id"
66-
).mapped("sale_ecotax_ids")
67-
ecotax_ids = sale_ecotaxes.filtered(
68-
lambda tax: tax.company_id == self.order_id.company_id
69-
)
70-
71-
if ecotax_ids and self.order_id.fiscal_position_id:
72-
ecotax_ids = self.order_id.fiscal_position_id.map_tax(ecotax_ids)
73-
return ecotax_ids
41+
amount_unit, subtotal = line._get_ecotax_amounts()
42+
line.subtotal_ecotax = subtotal
43+
line.ecotax_amount_unit = amount_unit
7444

7545
@api.onchange("product_id")
7646
def _onchange_product_ecotax_line(self):
7747
"""Unlink and recreate ecotax_lines when modifying the product_id."""
48+
self.ecotax_line_ids.unlink()
7849
if self.product_id:
79-
self.ecotax_line_ids = [(5,)] # Remove all ecotax classification
8050
ecotax_cls_vals = []
8151
for ecotaxline_prod in self.product_id.all_ecotax_line_product_ids:
8252
classif_id = ecotaxline_prod.classification_id.id
@@ -92,8 +62,6 @@ def _onchange_product_ecotax_line(self):
9262
)
9363
)
9464
self.ecotax_line_ids = ecotax_cls_vals
95-
else:
96-
self.ecotax_line_ids = [(5,)]
9765

9866
def edit_ecotax_lines(self):
9967
view = {
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
* Mourad EL HADJ MIMOUNE <[email protected]>
2+
* Florian DA COSTA <[email protected]>
3+
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
This module is an extension of the module *l10n_fr_ecotax* for sale orders. Please refer to the README of the module *l10n_fr_ecotax* for more info about ecotax management.
1+
This module is an extension of the module *l10n_fr_ecotax* for sale orders. Please refer to the README of the module *account_ecotax* for more info about ecotax management.

account_ecotax_sale/static/description/index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ <h1 class="title">sale Ecotax Management</h1>
370370
!! source digest: sha256:731b0e3366890dbeca7db020b75324a2d458308b74991b4ce1d16937c9591178
371371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
372372
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/account-fiscal-rule/tree/16.0/account_ecotax_sale"><img alt="OCA/account-fiscal-rule" src="https://img.shields.io/badge/github-OCA%2Faccount--fiscal--rule-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/account-fiscal-rule-16-0/account-fiscal-rule-16-0-account_ecotax_sale"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/account-fiscal-rule&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
373-
<p>This module is an extension of the module <em>l10n_fr_ecotax</em> for sale orders. Please refer to the README of the module <em>l10n_fr_ecotax</em> for more info about ecotax management.</p>
373+
<p>This module is an extension of the module <em>l10n_fr_ecotax</em> for sale orders. Please refer to the README of the module <em>account_ecotax</em> for more info about ecotax management.</p>
374374
<p><strong>Table of contents</strong></p>
375375
<div class="contents local topic" id="contents">
376376
<ul class="simple">
@@ -403,6 +403,7 @@ <h2><a class="toc-backref" href="#toc-entry-3">Authors</a></h2>
403403
<h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
404404
<ul class="simple">
405405
<li>Mourad EL HADJ MIMOUNE &lt;<a class="reference external" href="mailto:mourad.elhadj.mimoune&#64;akretion.com">mourad.elhadj.mimoune&#64;akretion.com</a>&gt;</li>
406+
<li>Florian DA COSTA &lt;<a class="reference external" href="mailto:florian.dacosta&#64;akretion.com">florian.dacosta&#64;akretion.com</a>&gt;</li>
406407
</ul>
407408
</div>
408409
<div class="section" id="maintainers">
@@ -414,6 +415,8 @@ <h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
414415
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
415416
mission is to support the collaborative development of Odoo features and
416417
promote its widespread use.</p>
418+
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainers</a>:</p>
419+
<p><a class="reference external image-reference" href="https://github.com/mourad-ehm"><img alt="mourad-ehm" src="https://github.com/mourad-ehm.png?size=40px" /></a> <a class="reference external image-reference" href="https://github.com/florian-dacosta"><img alt="florian-dacosta" src="https://github.com/florian-dacosta.png?size=40px" /></a></p>
417420
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-fiscal-rule/tree/16.0/account_ecotax_sale">OCA/account-fiscal-rule</a> project on GitHub.</p>
418421
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
419422
</div>

0 commit comments

Comments
 (0)