Skip to content

Commit

Permalink
[16.0] add account_ecotax_sale module
Browse files Browse the repository at this point in the history
  • Loading branch information
mourad-ehm authored and bealdav committed Jun 7, 2024
1 parent c816411 commit e7c6912
Show file tree
Hide file tree
Showing 20 changed files with 1,251 additions and 0 deletions.
76 changes: 76 additions & 0 deletions account_ecotax_sale/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
======================
sale Ecotax Management
======================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:731b0e3366890dbeca7db020b75324a2d458308b74991b4ce1d16937c9591178
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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_sale
: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_sale
: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 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%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.

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.

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/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
18 changes: 18 additions & 0 deletions account_ecotax_sale/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# © 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",
"summary": "Sale Ecotaxe",
"version": "16.0.2.0.0",
"author": "Akretion,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-fiscal-rule",
"category": "Localization/Account Taxes",
"license": "AGPL-3",
"depends": ["account_ecotax", "sale"],
"data": [
"views/sale_view.xml",
"security/ir.model.access.csv",
],
"installable": True,
}
39 changes: 39 additions & 0 deletions account_ecotax_sale/i18n/account_ecotaxe_sale.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * l10n_fr_ecotaxe_sale
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.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: l10n_fr_ecotaxe_sale
#: model:ir.model.fields,field_description:l10n_fr_ecotaxe_sale.field_sale_order__amount_ecotaxe
msgid "Included Ecotaxe"
msgstr ""

#. module: l10n_fr_ecotaxe_sale
#: model:ir.model,name:l10n_fr_ecotaxe_sale.model_sale_order
msgid "Sales Order"
msgstr ""

#. module: l10n_fr_ecotaxe_sale
#: model:ir.model,name:l10n_fr_ecotaxe_sale.model_sale_order_line
msgid "Sales Order Line"
msgstr ""

#. module: l10n_fr_ecotaxe_sale
#: model:ir.model.fields,field_description:l10n_fr_ecotaxe_sale.field_sale_order_line__subtotal_ecotaxe
msgid "Subtotal Ecotaxe"
msgstr ""

#. module: l10n_fr_ecotaxe_sale
#: model:ir.model.fields,field_description:l10n_fr_ecotaxe_sale.field_sale_order_line__unit_ecotaxe_amount
msgid "ecotaxe Unit."
msgstr ""
42 changes: 42 additions & 0 deletions account_ecotax_sale/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * l10n_fr_ecotaxe_sale
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-03-01 13:01+0000\n"
"PO-Revision-Date: 2022-03-01 13:01+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: l10n_fr_ecotaxe_sale
#: model:ir.model.fields,field_description:l10n_fr_ecotaxe_sale.field_sale_order__amount_ecotaxe
msgid "Included Ecotaxe"
msgstr "Ecotaxe Incluse"

#. module: l10n_fr_ecotaxe_sale
#: model:ir.model,name:l10n_fr_ecotaxe_sale.model_sale_order
msgid "Sales Order"
msgstr "Bon de commande"

#. module: l10n_fr_ecotaxe_sale
#: model:ir.model,name:l10n_fr_ecotaxe_sale.model_sale_order_line
msgid "Sales Order Line"
msgstr "Ligne de bons de commande"

#. module: l10n_fr_ecotaxe_sale
#: model:ir.model.fields,field_description:l10n_fr_ecotaxe_sale.field_sale_order_line__subtotal_ecotaxe
msgid "Subtotal Ecotaxe"
msgstr "Sous-total Ecotaxe"

#. module: l10n_fr_ecotaxe_sale
#: model:ir.model.fields,field_description:l10n_fr_ecotaxe_sale.field_sale_order_line__unit_ecotaxe_amount
msgid "ecotaxe Unit."
msgstr "Ecotaxe par Unité"
142 changes: 142 additions & 0 deletions account_ecotax_sale/migrations/16.0.2.0.0/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# Copyright 2024 Akretion France (http://www.akretion.com/)
# @author Mourad EL HADJ MIMOUNE <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from openupgradelib import openupgrade


@openupgrade.migrate()
def migrate(env, version):
# Due to the bug of update module we need to deactivate view
openupgrade.logged_query(
env.cr,
"""
TRUNCATE TABLE account_ecotax_category RESTART IDENTITY CASCADE;
""",
)
openupgrade.logged_query(
env.cr,
"""
TRUNCATE TABLE ecotax_sector RESTART IDENTITY CASCADE;
""",
)
openupgrade.logged_query(
env.cr,
"""
TRUNCATE TABLE ecotax_collector RESTART IDENTITY CASCADE;
""",
)
openupgrade.logged_query(
env.cr,
"""
TRUNCATE TABLE account_ecotax_classification RESTART IDENTITY CASCADE;
""",
)
openupgrade.logged_query(
env.cr,
"""
TRUNCATE TABLE account_move_line_ecotax RESTART IDENTITY CASCADE;
""",
)
openupgrade.logged_query(
env.cr,
"""
TRUNCATE TABLE ecotax_line_product RESTART IDENTITY CASCADE;
""",
)
openupgrade.logged_query(
env.cr,
"""
INSERT INTO account_ecotax_category (name, code, description, active)
SELECT name, code, description, active FROM account_ecotaxe_category order by id;
""",
)

openupgrade.logged_query(
env.cr,
"""
INSERT INTO ecotax_sector (name, description, active)
SELECT name, description, active FROM ecotaxe_sector order by id;
""",
)
openupgrade.logged_query(
env.cr,
"""
INSERT INTO ecotax_collector (name, partner_id, active)
SELECT name, partner_id, active FROM ecotaxe_collector order by id;
""",
)
openupgrade.logged_query(
env.cr,
"""
ALTER TABLE account_ecotax_classification ADD COLUMN old_id INTEGER;
""",
)
openupgrade.logged_query(
env.cr,
"""
INSERT INTO account_ecotax_classification (name, code, ecotax_type, ecotax_coef, default_fixed_ecotax,
categ_id, sector_id, collector_id, active, company_id,
product_status, supplier_status, emebi_code, scale_code, old_id)
SELECT name, code, ecotaxe_type, ecotaxe_coef, default_fixed_ecotaxe,
categ_id, sector_id, collector_id, active, company_id,
product_status, supplier_status, emebi_code, scale_code, id FROM account_ecotaxe_classification order by id;
""", # noqa
)
openupgrade.logged_query(
env.cr,
"""
UPDATE account_move SET amount_ecotax = amount_ecotaxe;
""",
)
openupgrade.logged_query(
env.cr,
"""
UPDATE account_move_line SET subtotal_ecotax = subtotal_ecotaxe, ecotax_amount_unit = ecotaxe_amount_unit;
""", # noqa
)
openupgrade.logged_query(
env.cr,
"""
INSERT INTO account_move_line_ecotax (classification_id, account_move_line_id, amount_unit, force_amount_unit, amount_total)
SELECT cls.id, account_move_line_id, amount_unit, force_amount_unit, amount_total FROM account_move_line_ecotaxe mle
INNER JOIN account_ecotax_classification cls on mle.classification_id = cls.old_id order by id;
""", # noqa
)

openupgrade.logged_query(
env.cr,
"""
INSERT INTO ecotax_line_product (product_tmpl_id, product_id, classification_id, force_amount, amount)
SELECT product_tmplt_id, product_id, cls.id, force_amount, amount FROM ecotaxe_line_product lp
INNER JOIN account_ecotax_classification cls on lp.classification_id = cls.old_id
order by id;
""", # noqa
)
openupgrade.logged_query(
env.cr,
"""
UPDATE product_product SET ecotax_amount = ecotaxe_amount;
""",
)
openupgrade.logged_query(
env.cr,
"""
UPDATE product_template SET ecotax_amount = ecotaxe_amount;
""",
)
openupgrade.logged_query(
env.cr,
"""
INSERT INTO sale_order_line_ecotax (classification_id, sale_order_line_id, amount_unit, force_amount_unit, amount_total)
SELECT cls.id, sale_order_line_id, amount_unit, force_amount_unit, amount_total FROM sale_order_line_ecotaxe ole
INNER JOIN account_ecotax_classification cls on ole.classification_id = cls.old_id order by id;
""", # noqa
)

openupgrade.logged_query(
env.cr,
"""
ALTER TABLE account_ecotax_classification DROP COLUMN old_id;
""",
)
3 changes: 3 additions & 0 deletions account_ecotax_sale/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import sale_order_line_ecotax
from . import sale_order_line
from . import sale_order
25 changes: 25 additions & 0 deletions account_ecotax_sale/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# © 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 SaleOrder(models.Model):

_inherit = "sale.order"

amount_ecotax = fields.Float(
digits="Ecotaxe",
string="Included Ecotaxe",
store=True,
compute="_compute_ecotax",
)

@api.depends("order_line.subtotal_ecotax")
def _compute_ecotax(self):
for order in self:
val_ecotax = 0.0
for line in order.order_line:
val_ecotax += line.subtotal_ecotax
order.amount_ecotax = val_ecotax
Loading

0 comments on commit e7c6912

Please sign in to comment.