Skip to content

Commit 38f0f04

Browse files
committed
[16.0][IMP] rename fields in l10n_fr_ecotaxe module
[16.0][IMP] rename fields in l10n_fr_ecotaxe module rest of modif & imp product view
1 parent cd691c9 commit 38f0f04

14 files changed

+345
-122
lines changed

l10n_fr_ecotaxe/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"name": "France Custom Ecotaxe",
66
"summary": "Use Ecotaxe in French localisation contexte",
7-
"version": "16.0.1.0.0",
7+
"version": "16.0.2.0.0",
88
"author": "Akretion, Odoo Community Association (OCA)",
99
"website": "https://github.com/OCA/l10n-france",
1010
"category": "Localization/Account Taxes",
Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
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+
if not openupgrade.column_exists(
11+
env.cr, "account_ecotaxe_classification", "categ_id"
12+
):
13+
openupgrade.rename_fields(
14+
env,
15+
[
16+
(
17+
"account.ecotaxe.classification",
18+
"accoun_tecotaxe_classification",
19+
"account_ecotaxe_categ_id",
20+
"categ_id",
21+
),
22+
],
23+
)
24+
if not openupgrade.column_exists(
25+
env.cr, "account_ecotaxe_classification", "sector_id"
26+
):
27+
openupgrade.rename_fields(
28+
env,
29+
[
30+
(
31+
"account.ecotaxe.classification",
32+
"account_ecotaxe_classification",
33+
"ecotaxe_sector_id",
34+
"sector_id",
35+
),
36+
],
37+
)
38+
if not openupgrade.column_exists(
39+
env.cr, "account_ecotaxe_classification", "collector_id"
40+
):
41+
openupgrade.rename_fields(
42+
env,
43+
[
44+
(
45+
"account.ecotaxe.classification",
46+
"account_ecotaxe_classification",
47+
"ecotaxe_collector_id",
48+
"collector_id",
49+
),
50+
],
51+
)
52+
if not openupgrade.column_exists(
53+
env.cr, "account_ecotaxe_classification", "product_status"
54+
):
55+
openupgrade.rename_fields(
56+
env,
57+
[
58+
(
59+
"account.ecotaxe.classification",
60+
"account_ecotaxe_classification",
61+
"ecotaxe_product_status",
62+
"product_status",
63+
),
64+
],
65+
)
66+
if not openupgrade.column_exists(
67+
env.cr, "account_ecotaxe_classification", "supplier_status"
68+
):
69+
openupgrade.rename_fields(
70+
env,
71+
[
72+
(
73+
"account.ecotaxe.classification",
74+
"account_ecotaxe_classification",
75+
"ecotaxe_supplier_status",
76+
"supplier_status",
77+
),
78+
],
79+
)
80+
if not openupgrade.column_exists(
81+
env.cr, "account_ecotaxe_classification", "emebi_code"
82+
):
83+
openupgrade.rename_fields(
84+
env,
85+
[
86+
(
87+
"account.ecotaxe.classification",
88+
"account_ecotaxe_classification",
89+
"ecotaxe_deb_code",
90+
"emebi_code",
91+
),
92+
],
93+
)
94+
if not openupgrade.column_exists(
95+
env.cr, "account_ecotaxe_classification", "scale_code"
96+
):
97+
openupgrade.rename_fields(
98+
env,
99+
[
100+
(
101+
"account.ecotaxe.classification",
102+
"account_ecotaxe_classification",
103+
"ecotaxe_scale_code",
104+
"scale_code",
105+
),
106+
],
107+
)
108+
if not openupgrade.column_exists(
109+
env.cr, "account_move_line_ecotaxe", "classification_id"
110+
):
111+
openupgrade.rename_fields(
112+
env,
113+
[
114+
(
115+
"account.move.line.ecotaxe",
116+
"account_move_line_ecotaxe",
117+
"ecotaxe_classification_id",
118+
"classification_id",
119+
),
120+
],
121+
)
122+
if not openupgrade.column_exists(
123+
env.cr, "account_move_line_ecotaxe", "amount_unit"
124+
):
125+
openupgrade.rename_fields(
126+
env,
127+
[
128+
(
129+
"account.move.line.ecotaxe",
130+
"account_move_line_ecotaxe",
131+
"ecotaxe_amount_unit",
132+
"amount_unit",
133+
),
134+
],
135+
)
136+
if not openupgrade.column_exists(
137+
env.cr, "account_move_line_ecotaxe", "amount_total"
138+
):
139+
openupgrade.rename_fields(
140+
env,
141+
[
142+
(
143+
"account.move.line.ecotaxe",
144+
"account_move_line_ecotaxe",
145+
"ecotaxe_amount_total",
146+
"amount_total",
147+
),
148+
],
149+
)
150+
if not openupgrade.column_exists(
151+
env.cr, "account_move_line_ecotaxe", "force_amount_unit"
152+
):
153+
openupgrade.rename_fields(
154+
env,
155+
[
156+
(
157+
"account.move.line.ecotaxe",
158+
"account_move_line_ecotaxe",
159+
"force_ecotaxe_unit",
160+
"force_amount_unit",
161+
),
162+
],
163+
)
164+
if not openupgrade.column_exists(
165+
env.cr, "ecotaxe_line_product", "classification_id"
166+
):
167+
openupgrade.rename_fields(
168+
env,
169+
[
170+
(
171+
"ecotaxe.line.product",
172+
"ecotaxe_line_product",
173+
"ecotaxe_classification_id",
174+
"classification_id",
175+
),
176+
],
177+
)
178+
if not openupgrade.column_exists(env.cr, "ecotaxe_line_product", "force_amount"):
179+
openupgrade.rename_fields(
180+
env,
181+
[
182+
(
183+
"ecotaxe.line.product",
184+
"ecotaxe_line_product",
185+
"force_ecotaxe_amount",
186+
"force_amount",
187+
),
188+
],
189+
)
190+
if not openupgrade.column_exists(env.cr, "ecotaxe_line_product", "amount"):
191+
openupgrade.rename_fields(
192+
env,
193+
[
194+
(
195+
"ecotaxe.line.product",
196+
"ecotaxe_line_product",
197+
"ecotaxe_amount",
198+
"amount",
199+
),
200+
],
201+
)

l10n_fr_ecotaxe/models/account_ecotaxe_classification.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ def _default_company_id(self):
2424
)
2525
ecotaxe_coef = fields.Float(digits="Ecotaxe")
2626
default_fixed_ecotaxe = fields.Float(help="Default fixed ecotaxe amount.")
27-
account_ecotaxe_categ_id = fields.Many2one(
27+
categ_id = fields.Many2one(
2828
comodel_name="account.ecotaxe.category",
29-
string="Ecotaxe category",
29+
string="Category",
3030
)
31-
ecotaxe_sector_id = fields.Many2one(
31+
sector_id = fields.Many2one(
3232
comodel_name="ecotaxe.sector",
3333
string="Ecotaxe sector",
3434
)
35-
ecotaxe_collector_id = fields.Many2one(
35+
collector_id = fields.Many2one(
3636
comodel_name="ecotaxe.collector",
3737
string="Ecotaxe collector",
3838
)
@@ -45,20 +45,18 @@ def _default_company_id(self):
4545
" company. Otherwise, this Fiscal Classification will be available"
4646
" for all companies.",
4747
)
48-
ecotaxe_product_status = fields.Selection(
48+
product_status = fields.Selection(
4949
[("M", "Menager"), ("P", "Professionnel")],
50-
string="Product Status",
5150
required=True,
5251
)
53-
ecotaxe_supplier_status = fields.Selection(
52+
supplier_status = fields.Selection(
5453
[
5554
("FAB", "Fabricant"),
5655
("REV", "Revendeur sous sa marque"),
5756
("INT", "Introducteur"),
5857
("IMP", "Importateur"),
5958
("DIS", "Vendeur à distance"),
6059
],
61-
string="Supplier Status",
6260
required=True,
6361
help="FAB ==> Fabricant : est établi en France et fabrique des EEE\n"
6462
"sous son propre nom ou sa propre marque, ou fait concevoir ou\n"
@@ -75,8 +73,8 @@ def _default_company_id(self):
7573
"membre ou dans un pays tiers et vend en France des EEE par\n"
7674
"communication à distance",
7775
)
78-
ecotaxe_deb_code = fields.Char()
79-
ecotaxe_scale_code = fields.Char()
76+
emebi_code = fields.Char()
77+
scale_code = fields.Char()
8078

8179
@api.onchange("ecotaxe_type")
8280
def _onchange_ecotaxe_type(self):

l10n_fr_ecotaxe/models/account_move_line.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ class AcountMoveLine(models.Model):
2424
@api.depends(
2525
"move_id.currency_id",
2626
"ecotaxe_line_ids",
27-
"ecotaxe_line_ids.ecotaxe_amount_unit",
28-
"ecotaxe_line_ids.ecotaxe_amount_total",
27+
"ecotaxe_line_ids.amount_unit",
28+
"ecotaxe_line_ids.amount_total",
2929
)
3030
def _compute_ecotaxe(self):
3131
for line in self:
32-
unit = sum(line.ecotaxe_line_ids.mapped("ecotaxe_amount_unit"))
33-
subtotal_ecotaxe = sum(line.ecotaxe_line_ids.mapped("ecotaxe_amount_total"))
32+
unit = sum(line.ecotaxe_line_ids.mapped("amount_unit"))
33+
subtotal_ecotaxe = sum(line.ecotaxe_line_ids.mapped("amount_total"))
3434

3535
if line.move_id.currency_id:
3636
unit = line.move_id.currency_id.round(unit)
@@ -49,15 +49,15 @@ def _onchange_product_ecotaxe_line(self):
4949
self.ecotaxe_line_ids = [(5,)] # Remove all ecotaxe classification
5050
ecotax_cls_vals = []
5151
for ecotaxeline_prod in self.product_id.all_ecotaxe_line_product_ids:
52-
classif_id = ecotaxeline_prod.ecotaxe_classification_id.id
53-
forced_amount = ecotaxeline_prod.force_ecotaxe_amount
52+
classif_id = ecotaxeline_prod.classification_id.id
53+
forced_amount = ecotaxeline_prod.force_amount
5454
ecotax_cls_vals.append(
5555
(
5656
0,
5757
0,
5858
{
59-
"ecotaxe_classification_id": classif_id,
60-
"force_ecotaxe_unit": forced_amount,
59+
"classification_id": classif_id,
60+
"force_amount_unit": forced_amount,
6161
},
6262
)
6363
)

l10n_fr_ecotaxe/models/account_move_line_ecotaxe.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
class AccountMoveLineEcotaxe(models.Model):
99
_name = "account.move.line.ecotaxe"
1010
_inherit = "ecotaxe.line.mixin"
11+
_description = "Account move line ecotaxe"
12+
1113
account_move_line_id = fields.Many2one(
1214
comodel_name="account.move.line",
1315
string="Account move line",

l10n_fr_ecotaxe/models/ecotaxe_line_mixin.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,44 +15,42 @@ class EcotaxeLineMixin(models.AbstractModel):
1515

1616
product_id = fields.Many2one("product.product", string="Product", readonly=True)
1717
currency_id = fields.Many2one("res.currency", string="Currency")
18-
ecotaxe_classification_id = fields.Many2one(
18+
classification_id = fields.Many2one(
1919
"account.ecotaxe.classification",
20-
string="Ecotaxe Classification",
20+
string="Classification",
2121
)
22-
ecotaxe_amount_unit = fields.Monetary(
22+
amount_unit = fields.Monetary(
2323
compute="_compute_ecotaxe",
2424
help="Ecotaxe Amount computed form Classification or Manuel ecotaxe",
2525
store=True,
2626
)
27-
force_ecotaxe_unit = fields.Monetary(
27+
force_amount_unit = fields.Monetary(
2828
help="Force ecotaxe.\n" "Allow to subtite default Ecotaxe Classification\n"
2929
)
30-
ecotaxe_amount_total = fields.Monetary(
30+
amount_total = fields.Monetary(
3131
compute="_compute_ecotaxe",
3232
help="Ecotaxe Amount total computed form Classification or forced ecotaxe amount",
3333
store=True,
3434
)
3535
quantity = fields.Float(digits="Product Unit of Measure", readonly=True)
3636

3737
@api.depends(
38-
"ecotaxe_classification_id",
39-
"force_ecotaxe_unit",
38+
"classification_id",
39+
"force_amount_unit",
4040
"product_id",
4141
"quantity",
4242
)
4343
def _compute_ecotaxe(self):
4444
for ecotaxeline in self:
45-
ecotax_cls = ecotaxeline.ecotaxe_classification_id
45+
ecotax_cls = ecotaxeline.classification_id
4646

4747
if ecotax_cls.ecotaxe_type == "weight_based":
4848
amt = ecotax_cls.ecotaxe_coef * (ecotaxeline.product_id.weight or 0.0)
4949
else:
5050
amt = ecotax_cls.default_fixed_ecotaxe
5151
# force ecotaxe amount
52-
if ecotaxeline.force_ecotaxe_unit:
53-
amt = ecotaxeline.force_ecotaxe_unit
52+
if ecotaxeline.force_amount_unit:
53+
amt = ecotaxeline.force_amount_unit
5454

55-
ecotaxeline.ecotaxe_amount_unit = amt
56-
ecotaxeline.ecotaxe_amount_total = (
57-
ecotaxeline.ecotaxe_amount_unit * ecotaxeline.quantity
58-
)
55+
ecotaxeline.amount_unit = amt
56+
ecotaxeline.amount_total = ecotaxeline.amount_unit * ecotaxeline.quantity

0 commit comments

Comments
 (0)