Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions account_ecotax_sale_tax/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
=================================
sale Ecotax Management (as a tax)
=================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:1bb5569058cef23c079b4a18bfe9e0ab55d3dff17a0eadb2ff8953f5850d14dd
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--fiscal--rule-lightgray.png?logo=github
:target: https://github.com/OCA/account-fiscal-rule/tree/17.0/account_ecotax_sale_tax
:alt: OCA/account-fiscal-rule
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-fiscal-rule-17-0/account-fiscal-rule-17-0-account_ecotax_sale_tax
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-fiscal-rule&target_branch=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

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.

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-fiscal-rule/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/account-fiscal-rule/issues/new?body=module:%20account_ecotax_sale_tax%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Akretion

Contributors
------------

- Mourad EL HADJ MIMOUNE <[email protected]>
- Florian DA COSTA <[email protected]>

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-mourad-ehm| image:: https://github.com/mourad-ehm.png?size=40px
:target: https://github.com/mourad-ehm
:alt: mourad-ehm
.. |maintainer-florian-dacosta| image:: https://github.com/florian-dacosta.png?size=40px
:target: https://github.com/florian-dacosta
:alt: florian-dacosta

Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-mourad-ehm| |maintainer-florian-dacosta|

This module is part of the `OCA/account-fiscal-rule <https://github.com/OCA/account-fiscal-rule/tree/17.0/account_ecotax_sale_tax>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions account_ecotax_sale_tax/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
17 changes: 17 additions & 0 deletions account_ecotax_sale_tax/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# © 2014-2023 Akretion (http://www.akretion.com)
# @author Mourad EL HADJ MIMOUNE <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "sale Ecotax Management (as a tax)",
"summary": "Sale Ecotaxe managed as a tax",
"version": "17.0.2.0.1",
"author": "Akretion,Odoo Community Association (OCA)",
"maintainers": ["mourad-ehm", "florian-dacosta"],
"website": "https://github.com/OCA/account-fiscal-rule",
"category": "Localization/Account Taxes",
"license": "AGPL-3",
"depends": ["account_ecotax_sale", "account_ecotax_tax"],
"data": ["views/sale_view.xml"],
"installable": True,
"auto_install": True,
}
29 changes: 29 additions & 0 deletions account_ecotax_sale_tax/i18n/account_ecotax_sale_tax.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_ecotax_sale_tax
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: account_ecotax_sale_tax
#: model:ir.model.fields,field_description:account_ecotax_sale_tax.field_sale_order_line__subtotal_ecotax
msgid "Ecotax"
msgstr ""

#. module: account_ecotax_sale_tax
#: model:ir.model.fields,field_description:account_ecotax_sale_tax.field_sale_order_line__ecotax_amount_unit
msgid "Ecotax Unit"
msgstr ""

#. module: account_ecotax_sale_tax
#: model:ir.model,name:account_ecotax_sale_tax.model_sale_order_line
msgid "Sales Order Line"
msgstr ""
32 changes: 32 additions & 0 deletions account_ecotax_sale_tax/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_ecotax_sale_tax
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2025-03-18 19:06+0000\n"
"Last-Translator: mymage <[email protected]>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 5.10.2\n"

#. module: account_ecotax_sale_tax
#: model:ir.model.fields,field_description:account_ecotax_sale_tax.field_sale_order_line__subtotal_ecotax
msgid "Ecotax"
msgstr "Imposta ecologica"

#. module: account_ecotax_sale_tax
#: model:ir.model.fields,field_description:account_ecotax_sale_tax.field_sale_order_line__ecotax_amount_unit
msgid "Ecotax Unit"
msgstr "Unità imposta ecologica"

#. module: account_ecotax_sale_tax
#: model:ir.model,name:account_ecotax_sale_tax.model_sale_order_line
msgid "Sales Order Line"
msgstr "Riga ordine di vendita"
1 change: 1 addition & 0 deletions account_ecotax_sale_tax/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import sale_order_line
85 changes: 85 additions & 0 deletions account_ecotax_sale_tax/models/sale_order_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# © 2015 -2023 Akretion (http://www.akretion.com)
# @author Mourad EL HADJ MIMOUNE <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import api, fields, models


class SaleOrderLine(models.Model):
_inherit = "sale.order.line"

subtotal_ecotax = fields.Float(compute="_compute_ecotax_tax")
ecotax_amount_unit = fields.Float(
compute="_compute_ecotax_tax",
)

def _get_ecotax_amounts(self):
self.ensure_one()
# do not call super as we completly change the way to compute it
ecotax_ids = self.tax_id.filtered(lambda tax: tax.is_ecotax)
if (self.display_type and self.display_type != "product") or not ecotax_ids:
return 0.0, 0.0
amount_currency = self.price_unit * (1 - self.discount / 100)
quantity = self.product_uom_qty
compute_all_currency = ecotax_ids.compute_all(
amount_currency,
currency=self.currency_id,
quantity=quantity,
product=self.product_id,
partner=self.order_id.partner_shipping_id,
)
subtotal_ecotax = 0.0
for tax in compute_all_currency["taxes"]:
subtotal_ecotax += tax["amount"]

unit = quantity and subtotal_ecotax / quantity or subtotal_ecotax
return unit, subtotal_ecotax

@api.depends(
"tax_id",
"product_uom_qty",
"product_id",
)
def _compute_ecotax_tax(self):
return self._compute_ecotax()

def _get_new_vals_list(self):
if not self.subtotal_ecotax:
return []
return super()._get_new_vals_list()

# ensure lines are re-generated in case ecotax_amount_unit of invoice line change
# without changing the product
@api.depends("ecotax_amount_unit", "subtotal_ecotax")
def _compute_ecotax_line_ids(self):
return super()._compute_ecotax_line_ids()

@api.depends("product_id", "company_id")
def _compute_tax_id(self):
res = super()._compute_tax_id()
for line in self:
line.tax_id |= line._get_computed_ecotaxes()
return res

def _get_computed_ecotaxes(self):
self.ensure_one()
sale_ecotaxes = self.product_id.all_ecotax_line_product_ids.mapped(
"classification_id"
).mapped("sale_ecotax_ids")
ecotax_ids = sale_ecotaxes.filtered(
lambda tax: tax.company_id == self.order_id.company_id
)

if ecotax_ids and self.order_id.fiscal_position_id:
ecotax_ids = self.order_id.fiscal_position_id.map_tax(ecotax_ids)
return ecotax_ids

def _prepare_invoice_line(self, **optional_values):
res = super()._prepare_invoice_line(**optional_values)
# remove ecoltax_line_ids value if empty in vals so it is recomputed during
# invoice line creation. Example of use case : Ship a product not present in
# SO. So line is created with qty 0 (so with no ecotax) but in invoice it is
# added with a qty, with ecotax, so we want to recompute the ecotax report lines
if "ecotax_line_ids" in res and not res["ecotax_line_ids"]:
res.pop("ecotax_line_ids")
return res
3 changes: 3 additions & 0 deletions account_ecotax_sale_tax/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
2 changes: 2 additions & 0 deletions account_ecotax_sale_tax/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Mourad EL HADJ MIMOUNE \<<[email protected]>\>
- Florian DA COSTA \<<[email protected]>\>
3 changes: 3 additions & 0 deletions account_ecotax_sale_tax/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading