Skip to content

Commit

Permalink
[16.0][FIX] fix digits precision & add post-migration script
Browse files Browse the repository at this point in the history
  • Loading branch information
mourad-ehm committed Feb 8, 2024
1 parent f458fa6 commit 245b535
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
35 changes: 35 additions & 0 deletions l10n_fr_ecotaxe_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)
""",
)
8 changes: 4 additions & 4 deletions l10n_fr_ecotaxe_sale/models/sale_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ class SaleOrderLine(models.Model):
string="Ecotaxe lines",
copy=True,
)
subtotal_ecotaxe = fields.Float(store=True, compute="_compute_ecotaxe")
subtotal_ecotaxe = fields.Float(
digits="Ecotaxe", store=True, compute="_compute_ecotaxe"
)
ecotaxe_amount_unit = fields.Float(
digits="Ecotaxe",
string="ecotaxe Unit.",
store=True,
compute="_compute_ecotaxe",
Expand All @@ -33,9 +36,6 @@ def _compute_ecotaxe(self):
unit = sum(line.ecotaxe_line_ids.mapped("amount_unit"))
subtotal_ecotaxe = sum(line.ecotaxe_line_ids.mapped("amount_total"))

if line.currency_id:
unit = line.currency_id.round(unit)
subtotal_ecotaxe = line.currency_id.round(subtotal_ecotaxe)
line.update(
{
"ecotaxe_amount_unit": unit,
Expand Down

0 comments on commit 245b535

Please sign in to comment.