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 committed May 27, 2024
1 parent c816411 commit 3db6673
Show file tree
Hide file tree
Showing 19 changed files with 1,204 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 @@
===================
France sale Ecotaxe
===================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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": "France sale Ecotaxe",
"summary": "Sale Ecotaxe used in French localisation contexte",
"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": ["l10n_fr_ecotaxe", "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é"
35 changes: 35 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,35 @@
# 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,
"""
UPDATE ir_ui_view set
active = True
WHERE id in (
SELECT "ir_ui_view".id FROM "ir_ui_view"
WHERE (("ir_ui_view"."active" = False)
AND (unaccent(COALESCE("ir_ui_view"."arch_db"->>'fr_FR',
"ir_ui_view"."arch_db"->>'en_US')) ilike unaccent('%classification_id%')))
)
""",
)
openupgrade.logged_query(
env.cr,
"""
UPDATE ir_ui_view set
active = False WHERE id in (
SELECT "ir_ui_view".id FROM "ir_ui_view"
WHERE (("ir_ui_view"."active" = true)
AND (unaccent(COALESCE("ir_ui_view"."arch_db"->>'fr_FR',
"ir_ui_view"."arch_db"->>'en_US')) ilike unaccent('%ecotaxe_classification_id%')))
ORDER BY "ir_ui_view"."priority" ASC LIMIT 80)
""",
)
61 changes: 61 additions & 0 deletions account_ecotax_sale/migrations/16.0.2.0.0/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# 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):
if not openupgrade.column_exists(
env.cr, "sale_order_line_ecotaxe", "classification_id"
):
openupgrade.rename_fields(
env,
[
(
"sale.order.line.ecotaxe",
"sale_order_line_ecotaxe",
"ecotaxe_classification_id",
"classification_id",
),
],
)
if not openupgrade.column_exists(env.cr, "sale_order_line_ecotaxe", "amount_unit"):
openupgrade.rename_fields(
env,
[
(
"sale.order.line.ecotaxe",
"sale_order_line_ecotaxe",
"ecotaxe_amount_unit",
"amount_unit",
),
],
)
if not openupgrade.column_exists(env.cr, "sale_order_line_ecotaxe", "amount_total"):
openupgrade.rename_fields(
env,
[
(
"sale.order.line.ecotaxe",
"sale_order_line_ecotaxe",
"ecotaxe_amount_total",
"amount_total",
),
],
)
if not openupgrade.column_exists(
env.cr, "sale_order_line_ecotaxe", "force_amount_unit"
):
openupgrade.rename_fields(
env,
[
(
"sale.order.line.ecotaxe",
"sale_order_line_ecotaxe",
"force_ecotaxe_unit",
"force_amount_unit",
),
],
)
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 3db6673

Please sign in to comment.