Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP [16.0] add account_ecotax module #428

Open
wants to merge 13 commits into
base: 16.0
Choose a base branch
from
Open
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ jobs:
matrix:
include:
- container: ghcr.io/oca/oca-ci/py3.10-odoo16.0:latest
exclude: "account_product_fiscal_classification"
name: test with Odoo
- container: ghcr.io/oca/oca-ci/py3.10-ocb16.0:latest
exclude: "account_product_fiscal_classification"
name: test with OCB
makepot: "true"
services:
Expand Down
153 changes: 153 additions & 0 deletions account_ecotax/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
=================
Ecotax Management
=================

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

.. |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/16.0/account_ecotax
: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-16-0/account-fiscal-rule-16-0-account_ecotax
: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=16.0
:alt: Try me on Runboat

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

This module applies to companies based in France mainland. It doesn't apply to
companies based in the DOM-TOMs (Guadeloupe, Martinique, Guyane, Réunion,
Mayotte).

It add Ecotaxe amount on invoice line.
furthermore, a total ecotaxe are added at the footer of each document.

To make easy ecotaxe management and to factor the data, ecotaxe are set on products via ECOTAXE classifications.
ECOTAXE classification can either a fixed or weight based ecotaxe.

A product can have one or serveral ecotaxe classifications. For exemple wooden window blinds equipped with electric motor can
have ecotaxe for wood and ecotaxe for electric motor.

This module version add the possibility to manage several ecotaxe classification by product.
A migration script is necessary to update from previous versions.

There is the main change to manage in migration script:

renamed field
model old field new field
account.move.line unit_ecotaxe_amount ecotaxe_amount_unit
product.template manual_fixed_ecotaxe force_ecotaxe_amount

changed fields
model old field new field
product.template ecotaxe_classification_id ecotaxe_classification_ids

added fields
model new field
account.move.line ecotaxe_line_ids
product.template ecotaxe_line_product_ids

**Table of contents**

.. contents::
:local:

Usage
=====

1. Create a tax group named **"Ecotaxes"**. The sequence must be lower than other tax groups.
- Set the **Preceding Subtotal** field to **"Without Ecotax"**.

2. Create two taxes named **"Fixed Ecotax"** and **"Weight-Based Ecotax"**.
- Check the **Ecotax** checkbox.
- Set the correct Python code:

- For the fixed ecotax:

.. code-block:: python

result = quantity and product.fixed_ecotax * quantity or 0.0

- For the weight-based ecotax:

.. code-block:: python

result = quantity and product.weight_based_ecotax * quantity or 0.0

- Check the **Included in Base Amount** option.
- The sequence for Ecotax must be lower than the VAT tax.

3. For VAT taxes, check the **Base Affected by Previous Taxes?** option.

4. Add an ecotax classification via the menu **Accounting > Configuration > Taxes > Ecotax Classification**.

- The ecotax classification can be either a fixed ecotax or a weight-based ecotax.
- Ecotax classification information can be used for legal declarations.
- For the fixed ecotax, the ecotax amount is used as a default value, which can be overridden on the product.
- For the weight-based ecotax, define one ecotax by a coefficient applied to the weight (depending on the product's materials).
- Set the appropriate tax in the **Sale Ecotax** field.

5. Assign one or more ecotax classifications to a product.

- The ecotax amount can also be manually overridden on the product.

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%0Aversion:%2016.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]>

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

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

|maintainer-mourad-ehm|

This module is part of the `OCA/account-fiscal-rule <https://github.com/OCA/account-fiscal-rule/tree/16.0/account_ecotax>`_ 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/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
32 changes: 32 additions & 0 deletions account_ecotax/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# © 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": "Ecotax Management",
"summary": "Ecotax Management: in French context is a 'cost' "
"added to the sale price of electrical or electronic appliances or furnishing items",
"version": "16.0.1.0.0",
"author": "Akretion, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-fiscal-rule",
"category": "Localization/Account Taxes",
"license": "AGPL-3",
"maintainers": ["mourad-ehm"],
"depends": [
"account",
"account_tax_python",
],
"data": [
"data/decimal_precision.xml",
"security/ir_rule.xml",
"security/ir.model.access.csv",
"views/account_ecotax_category_view.xml",
"views/ecotax_sector_view.xml",
"views/ecotax_collector_view.xml",
"views/account_ecotax_classification_view.xml",
"views/account_move_view.xml",
"views/product_template_view.xml",
"views/product_view.xml",
"views/account_tax_view.xml",
],
"installable": True,
}
7 changes: 7 additions & 0 deletions account_ecotax/data/decimal_precision.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<record id="ecotaxe_decimal" model="decimal.precision">
<field name="name">Ecotax</field>
<field name="digits">4</field>
</record>
</odoo>
12 changes: 12 additions & 0 deletions account_ecotax/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from . import account_ecotax_category
from . import account_ecotax_classification
from . import account_move
from . import account_move_line
from . import ecotax_line_product
from . import product_template
from . import ecotax_line_mixin
from . import account_move_line_ecotax
from . import product_product
from . import ecotax_sector
from . import ecotax_collector
from . import account_tax
15 changes: 15 additions & 0 deletions account_ecotax/models/account_ecotax_category.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2021 Camptocamp
# @author Silvio Gregorini <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


class AccountEcotaxCategory(models.Model):
_name = "account.ecotax.category"
_description = "Account Ecotax Category"

name = fields.Char(required=True)
code = fields.Char(required=True)
description = fields.Char()
active = fields.Boolean(default=True)
108 changes: 108 additions & 0 deletions account_ecotax/models/account_ecotax_classification.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# © 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).

from odoo import api, fields, models


class AccountEcotaxClassification(models.Model):
_name = "account.ecotax.classification"
_description = "Account Ecotax Classification"

name = fields.Char(required=True)
code = fields.Char()
ecotax_type = fields.Selection(
[("fixed", "Fixed"), ("weight_based", "Weight based")],
required=True,
help="If ecotax is weight based,"
"the ecotax coef must take into account\n"
"the weight unit of measure (kg by default)",
)
ecotax_coef = fields.Float(
digits="Ecotax", compute="_compute_ecotax_vals", readonly=False, store=True
)
default_fixed_ecotax = fields.Float(
digits="Ecotax",
help="Default fixed ecotax amount.",
compute="_compute_ecotax_vals",
readonly=False,
store=True,
)
categ_id = fields.Many2one(
comodel_name="account.ecotax.category",
string="Category",
)
sector_id = fields.Many2one(
comodel_name="ecotax.sector",
string="Ecotax sector",
)
collector_id = fields.Many2one(
comodel_name="ecotax.collector",
string="Ecotax collector",
)
active = fields.Boolean(default=True)
company_id = fields.Many2one(
comodel_name="res.company",
default=lambda self: self.env.company,
help="Specify a company"
" if you want to define this Ecotax Classification only for specific"
" company. Otherwise, this Fiscal Classification will be available"
" for all companies.",
)
product_status = fields.Selection(
[("M", "Menager"), ("P", "Professionnel")],
required=True,
)
supplier_status = fields.Selection(
[
("MAN", "Manufacturer"),
("RES", "Reseller, under their own brand"),
("INT", "Introducer"),
("IMP", "Importer"),
("REM", "Remote vendor"),
],
required=True,
help="MAN ==> Manufacturer: is locally established in the country, "
"and manufactures goods which are subject to ecotaxes\n"
"under their own name and brand, or designs such goods, "
"subcontracts the manufacturing and then sells them under "
"their own name and brand\n"
"RES ==> Reseller, under their own brand: is locally established "
"in the country, and sells under their own name or brand goods"
" subject to ecotax manufactured by others\n"
"INT ==> Introducer: is locally established and sells on the local "
"market goods subject to ecotax coming from other countries "
"of the European Union\n"
"IMP ==> Importer: is established in France, and sells on the local"
" market goods subject to ecotax coming from countries outside"
"the European Union\n"
"REM ==> Remote vendor: is established in another country of "
"the European Union or outside the EU, and remotely sells good "
"subject to ecotaxes to customers in the country",
)
intrastat_code = fields.Char()
scale_code = fields.Char()
sale_ecotax_ids = fields.Many2many(
"account.tax",
"ecotax_classif_taxes_rel",
"ecotax_classif_id",
"tax_id",
string="Sale EcoTax",
domain=[("is_ecotax", "=", True), ("type_tax_use", "=", "sale")],
)
purchase_ecotax_ids = fields.Many2many(
"account.tax",
"ecotax_classif_purchase_taxes_rel",
"ecotax_classif_id",
"tax_id",
string="Purchase EcoTax",
domain=[("is_ecotax", "=", True), ("type_tax_use", "=", "purchase")],
)

@api.depends("ecotax_type")
def _compute_ecotax_vals(self):
for classif in self:
if classif.ecotax_type == "weight_based":
classif.default_fixed_ecotax = 0

Check warning on line 106 in account_ecotax/models/account_ecotax_classification.py

View check run for this annotation

Codecov / codecov/patch

account_ecotax/models/account_ecotax_classification.py#L106

Added line #L106 was not covered by tests
elif classif.ecotax_type == "fixed":
classif.ecotax_coef = 0

Check warning on line 108 in account_ecotax/models/account_ecotax_classification.py

View check run for this annotation

Codecov / codecov/patch

account_ecotax/models/account_ecotax_classification.py#L108

Added line #L108 was not covered by tests
Loading
Loading