Skip to content

Commit a046ea6

Browse files
committed
[16.0][FIX] fix amount digits precision & view update error
[16.0][FIX] fix psot-migration view load bug [16.0][FIX] fix digits precision for ecotaxe amount on invoice & product & fixed ecotaxe [16.0][FIX] tests [16.0][FIX] replace onchange by compute [16.0][FIX] pre-commit
1 parent 38f0f04 commit a046ea6

14 files changed

+110
-38
lines changed

l10n_fr_ecotaxe/README.rst

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ France Custom Ecotaxe
77
!! This file is generated by oca-gen-addon-readme !!
88
!! changes will be overwritten. !!
99
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10-
!! source digest: sha256:03df899941b30a17bd699f852929cc53708980e5cc79667d57c41486f8f809b9
10+
!! source digest: sha256:23479e79cea1c7653013329021c55bf27b1d6fa0d64734b13f53ca3209feaffa
1111
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1212
1313
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
@@ -38,29 +38,28 @@ furthermore, a total ecotaxe are added at the footer of each document.
3838
To make easy ecotaxe management and to factor the data, ecotaxe are set on products via ECOTAXE classifications.
3939
ECOTAXE classification can either a fixed or weight based ecotaxe.
4040

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

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

47-
There is the main change to manage in migration script:
47+
There is the main change to manage in migration script:
4848

49-
renamed field
50-
model old field new field
49+
renamed field
50+
model old field new field
5151
account.move.line unit_ecotaxe_amount ecotaxe_amount_unit
5252
product.template manual_fixed_ecotaxe force_ecotaxe_amount
5353

54-
changed fields
55-
model old field new field
54+
changed fields
55+
model old field new field
5656
product.template ecotaxe_classification_id ecotaxe_classification_ids
5757

5858
added fields
5959
model new field
6060
account.move.line ecotaxe_line_ids
6161
product.template ecotaxe_line_product_ids
6262

63-
6463
**Table of contents**
6564

6665
.. contents::

l10n_fr_ecotaxe/data/decimal_precision.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
<odoo noupdate="1">
33
<record id="ecotaxe_decimal" model="decimal.precision">
44
<field name="name">Ecotaxe</field>
5-
<field name="digits">3</field>
5+
<field name="digits">4</field>
66
</record>
77
</odoo>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
UPDATE ir_ui_view set
15+
active = True
16+
WHERE id in (
17+
SELECT "ir_ui_view".id FROM "ir_ui_view"
18+
WHERE (("ir_ui_view"."active" = False)
19+
AND (unaccent(COALESCE("ir_ui_view"."arch_db"->>'fr_FR',
20+
"ir_ui_view"."arch_db"->>'en_US')) ilike unaccent('%classification_id%')))
21+
)
22+
""",
23+
)
24+
openupgrade.logged_query(
25+
env.cr,
26+
"""
27+
UPDATE ir_ui_view set
28+
active = False WHERE id in (
29+
SELECT "ir_ui_view".id FROM "ir_ui_view"
30+
WHERE (("ir_ui_view"."active" = true)
31+
AND (unaccent(COALESCE("ir_ui_view"."arch_db"->>'fr_FR',
32+
"ir_ui_view"."arch_db"->>'en_US')) ilike unaccent('%ecotaxe_classification_id%')))
33+
ORDER BY "ir_ui_view"."priority" ASC LIMIT 80)
34+
""",
35+
)

l10n_fr_ecotaxe/migrations/16.0.2.0.0/pre-migration.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,21 @@
77

88
@openupgrade.migrate()
99
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+
UPDATE ir_ui_view set
15+
active = False
16+
WHERE id in (
17+
SELECT "ir_ui_view".id FROM "ir_ui_view"
18+
WHERE (("ir_ui_view"."active" = true)
19+
AND (unaccent(COALESCE("ir_ui_view"."arch_db"->>'fr_FR',
20+
"ir_ui_view"."arch_db"->>'en_US')) ilike unaccent('%ecotaxe_classification_id%')))
21+
ORDER BY "ir_ui_view"."priority" ASC LIMIT 80
22+
)
23+
""",
24+
)
1025
if not openupgrade.column_exists(
1126
env.cr, "account_ecotaxe_classification", "categ_id"
1227
):

l10n_fr_ecotaxe/models/account_ecotaxe_classification.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,16 @@ def _default_company_id(self):
2222
"the ecotaxe coef must take into account\n"
2323
"the weight unit of measure (kg by default)",
2424
)
25-
ecotaxe_coef = fields.Float(digits="Ecotaxe")
26-
default_fixed_ecotaxe = fields.Float(help="Default fixed ecotaxe amount.")
25+
ecotaxe_coef = fields.Float(
26+
digits="Ecotaxe", compute="_compute_ecotaxe_vals", readonly=False, store=True
27+
)
28+
default_fixed_ecotaxe = fields.Float(
29+
digits="Ecotaxe",
30+
help="Default fixed ecotaxe amount.",
31+
compute="_compute_ecotaxe_vals",
32+
readonly=False,
33+
store=True,
34+
)
2735
categ_id = fields.Many2one(
2836
comodel_name="account.ecotaxe.category",
2937
string="Category",
@@ -76,9 +84,10 @@ def _default_company_id(self):
7684
emebi_code = fields.Char()
7785
scale_code = fields.Char()
7886

79-
@api.onchange("ecotaxe_type")
80-
def _onchange_ecotaxe_type(self):
81-
if self.ecotaxe_type == "weight_based":
82-
self.default_fixed_ecotaxe = 0
83-
if self.ecotaxe_type == "fixed":
84-
self.ecotaxe_coef = 0
87+
@api.depends("ecotaxe_type")
88+
def _compute_ecotaxe_vals(self):
89+
for classif in self:
90+
if classif.ecotaxe_type == "weight_based":
91+
classif.default_fixed_ecotaxe = 0
92+
if classif.ecotaxe_type == "fixed":
93+
classif.ecotaxe_coef = 0

l10n_fr_ecotaxe/models/account_move.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
class AccountMove(models.Model):
1010
_inherit = "account.move"
1111

12-
amount_ecotaxe = fields.Monetary(
13-
string="Included Ecotaxe", store=True, compute="_compute_ecotaxe"
12+
amount_ecotaxe = fields.Float(
13+
digits="Ecotaxe",
14+
string="Included Ecotaxe",
15+
store=True,
16+
compute="_compute_ecotaxe",
1417
)
1518

1619
@api.depends("invoice_line_ids.subtotal_ecotaxe")

l10n_fr_ecotaxe/models/account_move_line.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ class AcountMoveLine(models.Model):
1414
string="Ecotaxe lines",
1515
copy=True,
1616
)
17-
subtotal_ecotaxe = fields.Float(store=True, compute="_compute_ecotaxe")
17+
subtotal_ecotaxe = fields.Float(
18+
digits="Ecotaxe", store=True, compute="_compute_ecotaxe"
19+
)
1820
ecotaxe_amount_unit = fields.Float(
21+
digits="Ecotaxe",
1922
string="Ecotaxe Unit.",
2023
store=True,
2124
compute="_compute_ecotaxe",
@@ -32,9 +35,6 @@ def _compute_ecotaxe(self):
3235
unit = sum(line.ecotaxe_line_ids.mapped("amount_unit"))
3336
subtotal_ecotaxe = sum(line.ecotaxe_line_ids.mapped("amount_total"))
3437

35-
if line.move_id.currency_id:
36-
unit = line.move_id.currency_id.round(unit)
37-
subtotal_ecotaxe = line.move_id.currency_id.round(subtotal_ecotaxe)
3838
line.update(
3939
{
4040
"ecotaxe_amount_unit": unit,

l10n_fr_ecotaxe/models/ecotaxe_line_mixin.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,18 @@ class EcotaxeLineMixin(models.AbstractModel):
1919
"account.ecotaxe.classification",
2020
string="Classification",
2121
)
22-
amount_unit = fields.Monetary(
22+
amount_unit = fields.Float(
23+
digits="Ecotaxe",
2324
compute="_compute_ecotaxe",
2425
help="Ecotaxe Amount computed form Classification or Manuel ecotaxe",
2526
store=True,
2627
)
27-
force_amount_unit = fields.Monetary(
28-
help="Force ecotaxe.\n" "Allow to subtite default Ecotaxe Classification\n"
28+
force_amount_unit = fields.Float(
29+
digits="Ecotaxe",
30+
help="Force ecotaxe.\n" "Allow to subtite default Ecotaxe Classification\n",
2931
)
30-
amount_total = fields.Monetary(
32+
amount_total = fields.Float(
33+
digits="Ecotaxe",
3134
compute="_compute_ecotaxe",
3235
help="Ecotaxe Amount total computed form Classification or forced ecotaxe amount",
3336
store=True,

l10n_fr_ecotaxe/models/ecotaxe_line_product.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ class EcotaxeLineProduct(models.Model):
2020
"account.ecotaxe.classification",
2121
string="Classification",
2222
)
23-
force_amount = fields.Monetary(
23+
force_amount = fields.Float(
24+
digits="Ecotaxe",
2425
help="Force ecotaxe amount.\n"
25-
"Allow to substitute default Ecotaxe Classification\n"
26+
"Allow to substitute default Ecotaxe Classification\n",
2627
)
27-
amount = fields.Monetary(
28+
amount = fields.Float(
29+
digits="Ecotaxe",
2830
compute="_compute_ecotaxe",
2931
help="Ecotaxe Amount computed form Classification or forced ecotaxe amount",
3032
store=True,

l10n_fr_ecotaxe/models/product_product.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,13 @@ class ProductProduct(models.Model):
2323
compute="_compute_all_ecotaxe_line_product_ids",
2424
search="_search_all_ecotaxe_line_product_ids",
2525
string="All ecotaxe lines",
26+
help="Contain all ecotaxes classification defined in product template"
27+
"and the additionnal\n"
28+
"ecotaxes defined in product variant. For more details"
29+
"see the product variant accounting tab",
2630
)
27-
ecotaxe_amount = fields.Monetary(
31+
ecotaxe_amount = fields.Float(
32+
digits="Ecotaxe",
2833
compute="_compute_product_ecotaxe",
2934
help="Ecotaxe Amount computed form all ecotaxe line classification",
3035
store=True,

l10n_fr_ecotaxe/models/product_template.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class ProductTemplate(models.Model):
1414
string="Ecotaxe lines",
1515
copy=True,
1616
)
17-
ecotaxe_amount = fields.Monetary(
17+
ecotaxe_amount = fields.Float(
18+
digits="Ecotaxe",
1819
compute="_compute_ecotaxe",
1920
help="Ecotaxe Amount computed form Classification",
2021
store=True,

l10n_fr_ecotaxe/static/description/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ <h1 class="title">France Custom Ecotaxe</h1>
367367
!! This file is generated by oca-gen-addon-readme !!
368368
!! changes will be overwritten. !!
369369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370-
!! source digest: sha256:03df899941b30a17bd699f852929cc53708980e5cc79667d57c41486f8f809b9
370+
!! source digest: sha256:23479e79cea1c7653013329021c55bf27b1d6fa0d64734b13f53ca3209feaffa
371371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
372372
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/l10n-france/tree/16.0/l10n_fr_ecotaxe"><img alt="OCA/l10n-france" src="https://img.shields.io/badge/github-OCA%2Fl10n--france-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/l10n-france-16-0/l10n-france-16-0-l10n_fr_ecotaxe"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/l10n-france&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
373373
<p>This module applies to companies based in France mainland. It doesn’t apply to

l10n_fr_ecotaxe/tests/test_ecotaxe.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ def setUpClass(cls, chart_template_ref="l10n_fr.l10n_fr_pcg_chart_template"):
2525
"name": "Fixed Ecotax",
2626
"ecotaxe_type": "fixed",
2727
"default_fixed_ecotaxe": 5.0,
28-
"ecotaxe_product_status": "M",
29-
"ecotaxe_supplier_status": "FAB",
28+
"product_status": "M",
29+
"supplier_status": "FAB",
3030
}
3131
)
3232
# 2- Weight-based ecotax
@@ -35,8 +35,8 @@ def setUpClass(cls, chart_template_ref="l10n_fr.l10n_fr_pcg_chart_template"):
3535
"name": "Weight Based Ecotax",
3636
"ecotaxe_type": "weight_based",
3737
"ecotaxe_coef": 0.04,
38-
"ecotaxe_product_status": "P",
39-
"ecotaxe_supplier_status": "FAB",
38+
"product_status": "P",
39+
"supplier_status": "FAB",
4040
}
4141
)
4242

l10n_fr_ecotaxe/views/product_template_view.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<field name="inherit_id" ref="account.product_template_form_view" />
1212
<field name="arch" type="xml">
1313
<group name="properties" position="after">
14-
<group name="ecotaxe" colspan="2">
14+
<group name="ecotaxe" col="4">
1515
<label
1616
for="ecotaxe_line_product_ids"
1717
string="Product Template Ecotaxe classif"

0 commit comments

Comments
 (0)