Skip to content

Commit e7c6912

Browse files
mourad-ehmbealdav
authored andcommitted
[16.0] add account_ecotax_sale module
1 parent c816411 commit e7c6912

File tree

20 files changed

+1251
-0
lines changed

20 files changed

+1251
-0
lines changed

account_ecotax_sale/README.rst

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
======================
2+
sale Ecotax Management
3+
======================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:731b0e3366890dbeca7db020b75324a2d458308b74991b4ce1d16937c9591178
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--fiscal--rule-lightgray.png?logo=github
20+
:target: https://github.com/OCA/account-fiscal-rule/tree/16.0/account_ecotax_sale
21+
:alt: OCA/account-fiscal-rule
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/account-fiscal-rule-16-0/account-fiscal-rule-16-0-account_ecotax_sale
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-fiscal-rule&target_branch=16.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
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.
32+
33+
**Table of contents**
34+
35+
.. contents::
36+
:local:
37+
38+
Bug Tracker
39+
===========
40+
41+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-fiscal-rule/issues>`_.
42+
In case of trouble, please check there if your issue has already been reported.
43+
If you spotted it first, help us to smash it by providing a detailed and welcomed
44+
`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**>`_.
45+
46+
Do not contact contributors directly about support or help with technical issues.
47+
48+
Credits
49+
=======
50+
51+
Authors
52+
~~~~~~~
53+
54+
* Akretion
55+
56+
Contributors
57+
~~~~~~~~~~~~
58+
59+
* Mourad EL HADJ MIMOUNE <[email protected]>
60+
61+
Maintainers
62+
~~~~~~~~~~~
63+
64+
This module is maintained by the OCA.
65+
66+
.. image:: https://odoo-community.org/logo.png
67+
:alt: Odoo Community Association
68+
:target: https://odoo-community.org
69+
70+
OCA, or the Odoo Community Association, is a nonprofit organization whose
71+
mission is to support the collaborative development of Odoo features and
72+
promote its widespread use.
73+
74+
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.
75+
76+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

account_ecotax_sale/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# © 2014-2023 Akretion (http://www.akretion.com)
2+
# @author Mourad EL HADJ MIMOUNE <[email protected]>
3+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
4+
{
5+
"name": "sale Ecotax Management",
6+
"summary": "Sale Ecotaxe",
7+
"version": "16.0.2.0.0",
8+
"author": "Akretion,Odoo Community Association (OCA)",
9+
"website": "https://github.com/OCA/account-fiscal-rule",
10+
"category": "Localization/Account Taxes",
11+
"license": "AGPL-3",
12+
"depends": ["account_ecotax", "sale"],
13+
"data": [
14+
"views/sale_view.xml",
15+
"security/ir.model.access.csv",
16+
],
17+
"installable": True,
18+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * l10n_fr_ecotaxe_sale
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 15.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"Last-Translator: \n"
10+
"Language-Team: \n"
11+
"MIME-Version: 1.0\n"
12+
"Content-Type: text/plain; charset=UTF-8\n"
13+
"Content-Transfer-Encoding: \n"
14+
"Plural-Forms: \n"
15+
16+
#. module: l10n_fr_ecotaxe_sale
17+
#: model:ir.model.fields,field_description:l10n_fr_ecotaxe_sale.field_sale_order__amount_ecotaxe
18+
msgid "Included Ecotaxe"
19+
msgstr ""
20+
21+
#. module: l10n_fr_ecotaxe_sale
22+
#: model:ir.model,name:l10n_fr_ecotaxe_sale.model_sale_order
23+
msgid "Sales Order"
24+
msgstr ""
25+
26+
#. module: l10n_fr_ecotaxe_sale
27+
#: model:ir.model,name:l10n_fr_ecotaxe_sale.model_sale_order_line
28+
msgid "Sales Order Line"
29+
msgstr ""
30+
31+
#. module: l10n_fr_ecotaxe_sale
32+
#: model:ir.model.fields,field_description:l10n_fr_ecotaxe_sale.field_sale_order_line__subtotal_ecotaxe
33+
msgid "Subtotal Ecotaxe"
34+
msgstr ""
35+
36+
#. module: l10n_fr_ecotaxe_sale
37+
#: model:ir.model.fields,field_description:l10n_fr_ecotaxe_sale.field_sale_order_line__unit_ecotaxe_amount
38+
msgid "ecotaxe Unit."
39+
msgstr ""

account_ecotax_sale/i18n/fr.po

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * l10n_fr_ecotaxe_sale
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 15.0+e\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"POT-Creation-Date: 2022-03-01 13:01+0000\n"
10+
"PO-Revision-Date: 2022-03-01 13:01+0000\n"
11+
"Last-Translator: \n"
12+
"Language-Team: \n"
13+
"Language: \n"
14+
"MIME-Version: 1.0\n"
15+
"Content-Type: text/plain; charset=UTF-8\n"
16+
"Content-Transfer-Encoding: \n"
17+
"Plural-Forms: \n"
18+
19+
#. module: l10n_fr_ecotaxe_sale
20+
#: model:ir.model.fields,field_description:l10n_fr_ecotaxe_sale.field_sale_order__amount_ecotaxe
21+
msgid "Included Ecotaxe"
22+
msgstr "Ecotaxe Incluse"
23+
24+
#. module: l10n_fr_ecotaxe_sale
25+
#: model:ir.model,name:l10n_fr_ecotaxe_sale.model_sale_order
26+
msgid "Sales Order"
27+
msgstr "Bon de commande"
28+
29+
#. module: l10n_fr_ecotaxe_sale
30+
#: model:ir.model,name:l10n_fr_ecotaxe_sale.model_sale_order_line
31+
msgid "Sales Order Line"
32+
msgstr "Ligne de bons de commande"
33+
34+
#. module: l10n_fr_ecotaxe_sale
35+
#: model:ir.model.fields,field_description:l10n_fr_ecotaxe_sale.field_sale_order_line__subtotal_ecotaxe
36+
msgid "Subtotal Ecotaxe"
37+
msgstr "Sous-total Ecotaxe"
38+
39+
#. module: l10n_fr_ecotaxe_sale
40+
#: model:ir.model.fields,field_description:l10n_fr_ecotaxe_sale.field_sale_order_line__unit_ecotaxe_amount
41+
msgid "ecotaxe Unit."
42+
msgstr "Ecotaxe par Unité"
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
# Copyright 2024 Akretion France (http://www.akretion.com/)
2+
# @author Mourad EL HADJ MIMOUNE <[email protected]>
3+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
4+
5+
from openupgradelib import openupgrade
6+
7+
8+
@openupgrade.migrate()
9+
def migrate(env, version):
10+
# Due to the bug of update module we need to deactivate view
11+
openupgrade.logged_query(
12+
env.cr,
13+
"""
14+
TRUNCATE TABLE account_ecotax_category RESTART IDENTITY CASCADE;
15+
""",
16+
)
17+
openupgrade.logged_query(
18+
env.cr,
19+
"""
20+
TRUNCATE TABLE ecotax_sector RESTART IDENTITY CASCADE;
21+
""",
22+
)
23+
openupgrade.logged_query(
24+
env.cr,
25+
"""
26+
TRUNCATE TABLE ecotax_collector RESTART IDENTITY CASCADE;
27+
""",
28+
)
29+
openupgrade.logged_query(
30+
env.cr,
31+
"""
32+
TRUNCATE TABLE account_ecotax_classification RESTART IDENTITY CASCADE;
33+
""",
34+
)
35+
openupgrade.logged_query(
36+
env.cr,
37+
"""
38+
TRUNCATE TABLE account_move_line_ecotax RESTART IDENTITY CASCADE;
39+
""",
40+
)
41+
openupgrade.logged_query(
42+
env.cr,
43+
"""
44+
TRUNCATE TABLE ecotax_line_product RESTART IDENTITY CASCADE;
45+
""",
46+
)
47+
openupgrade.logged_query(
48+
env.cr,
49+
"""
50+
INSERT INTO account_ecotax_category (name, code, description, active)
51+
SELECT name, code, description, active FROM account_ecotaxe_category order by id;
52+
""",
53+
)
54+
55+
openupgrade.logged_query(
56+
env.cr,
57+
"""
58+
INSERT INTO ecotax_sector (name, description, active)
59+
SELECT name, description, active FROM ecotaxe_sector order by id;
60+
""",
61+
)
62+
openupgrade.logged_query(
63+
env.cr,
64+
"""
65+
INSERT INTO ecotax_collector (name, partner_id, active)
66+
SELECT name, partner_id, active FROM ecotaxe_collector order by id;
67+
""",
68+
)
69+
openupgrade.logged_query(
70+
env.cr,
71+
"""
72+
ALTER TABLE account_ecotax_classification ADD COLUMN old_id INTEGER;
73+
""",
74+
)
75+
openupgrade.logged_query(
76+
env.cr,
77+
"""
78+
INSERT INTO account_ecotax_classification (name, code, ecotax_type, ecotax_coef, default_fixed_ecotax,
79+
categ_id, sector_id, collector_id, active, company_id,
80+
product_status, supplier_status, emebi_code, scale_code, old_id)
81+
SELECT name, code, ecotaxe_type, ecotaxe_coef, default_fixed_ecotaxe,
82+
categ_id, sector_id, collector_id, active, company_id,
83+
product_status, supplier_status, emebi_code, scale_code, id FROM account_ecotaxe_classification order by id;
84+
""", # noqa
85+
)
86+
openupgrade.logged_query(
87+
env.cr,
88+
"""
89+
UPDATE account_move SET amount_ecotax = amount_ecotaxe;
90+
""",
91+
)
92+
openupgrade.logged_query(
93+
env.cr,
94+
"""
95+
UPDATE account_move_line SET subtotal_ecotax = subtotal_ecotaxe, ecotax_amount_unit = ecotaxe_amount_unit;
96+
""", # noqa
97+
)
98+
openupgrade.logged_query(
99+
env.cr,
100+
"""
101+
INSERT INTO account_move_line_ecotax (classification_id, account_move_line_id, amount_unit, force_amount_unit, amount_total)
102+
SELECT cls.id, account_move_line_id, amount_unit, force_amount_unit, amount_total FROM account_move_line_ecotaxe mle
103+
INNER JOIN account_ecotax_classification cls on mle.classification_id = cls.old_id order by id;
104+
""", # noqa
105+
)
106+
107+
openupgrade.logged_query(
108+
env.cr,
109+
"""
110+
INSERT INTO ecotax_line_product (product_tmpl_id, product_id, classification_id, force_amount, amount)
111+
SELECT product_tmplt_id, product_id, cls.id, force_amount, amount FROM ecotaxe_line_product lp
112+
INNER JOIN account_ecotax_classification cls on lp.classification_id = cls.old_id
113+
order by id;
114+
""", # noqa
115+
)
116+
openupgrade.logged_query(
117+
env.cr,
118+
"""
119+
UPDATE product_product SET ecotax_amount = ecotaxe_amount;
120+
""",
121+
)
122+
openupgrade.logged_query(
123+
env.cr,
124+
"""
125+
UPDATE product_template SET ecotax_amount = ecotaxe_amount;
126+
""",
127+
)
128+
openupgrade.logged_query(
129+
env.cr,
130+
"""
131+
INSERT INTO sale_order_line_ecotax (classification_id, sale_order_line_id, amount_unit, force_amount_unit, amount_total)
132+
SELECT cls.id, sale_order_line_id, amount_unit, force_amount_unit, amount_total FROM sale_order_line_ecotaxe ole
133+
INNER JOIN account_ecotax_classification cls on ole.classification_id = cls.old_id order by id;
134+
""", # noqa
135+
)
136+
137+
openupgrade.logged_query(
138+
env.cr,
139+
"""
140+
ALTER TABLE account_ecotax_classification DROP COLUMN old_id;
141+
""",
142+
)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from . import sale_order_line_ecotax
2+
from . import sale_order_line
3+
from . import sale_order
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# © 2015 -2023 Akretion (http://www.akretion.com)
2+
# @author Mourad EL HADJ MIMOUNE <[email protected]>
3+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
4+
5+
from odoo import api, fields, models
6+
7+
8+
class SaleOrder(models.Model):
9+
10+
_inherit = "sale.order"
11+
12+
amount_ecotax = fields.Float(
13+
digits="Ecotaxe",
14+
string="Included Ecotaxe",
15+
store=True,
16+
compute="_compute_ecotax",
17+
)
18+
19+
@api.depends("order_line.subtotal_ecotax")
20+
def _compute_ecotax(self):
21+
for order in self:
22+
val_ecotax = 0.0
23+
for line in order.order_line:
24+
val_ecotax += line.subtotal_ecotax
25+
order.amount_ecotax = val_ecotax

0 commit comments

Comments
 (0)