From d94f5676876d6fefd55183f1ced441015bff1b52 Mon Sep 17 00:00:00 2001 From: odooNextev Date: Fri, 12 Jan 2024 09:49:11 +0100 Subject: [PATCH] =?UTF-8?q?[IMP]=C2=A0l10n=5Fit=5Friba:=20add=20slip=20and?= =?UTF-8?q?=20slip=20line=20states=20mig?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migrations/16.0.1.0.0/post-migrate.py | 39 +++++++++++++------ .../migrations/16.0.1.0.0/pre-migrate.py | 15 +++++++ requirements.txt | 1 + 3 files changed, 43 insertions(+), 12 deletions(-) diff --git a/l10n_it_riba/migrations/16.0.1.0.0/post-migrate.py b/l10n_it_riba/migrations/16.0.1.0.0/post-migrate.py index 6c5d2d16e611..a3a61ca3180d 100644 --- a/l10n_it_riba/migrations/16.0.1.0.0/post-migrate.py +++ b/l10n_it_riba/migrations/16.0.1.0.0/post-migrate.py @@ -1,4 +1,5 @@ # Copyright 2023 Simone Rubino - AionTech +# Copyright 2024 Nextev Srl # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from openupgradelib import openupgrade @@ -13,19 +14,33 @@ def migrate(env, version): NEW_MODULE_NAME, "migrations/16.0.1.0.0/data/noupdate.xml", ) - # remove riba.distinta[.line].state refs - distinta_line_state_refs = env["ir.model.data"].search( + + openupgrade.map_values( + env.cr, + openupgrade.get_legacy_name("riba_distinta_line"), + "state", [ - ("module", "=", "l10n_it_riba"), - ("name", "like", "selection__riba_distinta_line__state__%"), - ] + ("draft", "draft"), + ("confirmed", "confirmed"), + ("accredited", "credited"), + ("paid", "paid"), + ("unsolved", "past_due"), + ("cancel", "cancel"), + ], + table="riba_slip_line", ) - distinta_line_state_refs.unlink() - # remove riba.distinta.state refs - distinta_line_refs = env["ir.model.data"].search( + + openupgrade.map_values( + env.cr, + openupgrade.get_legacy_name("riba_distinta"), + "state", [ - ("module", "=", "l10n_it_riba"), - ("name", "like", "selection__riba_distinta__state%%"), - ] + ("draft", "draft"), + ("accepted", "accepted"), + ("accredited", "credited"), + ("paid", "paid"), + ("unsolved", "past_due"), + ("cancel", "cancel"), + ], + table="riba_slip", ) - distinta_line_refs.unlink() diff --git a/l10n_it_riba/migrations/16.0.1.0.0/pre-migrate.py b/l10n_it_riba/migrations/16.0.1.0.0/pre-migrate.py index 992be0c8ba36..7ffabb62f5bf 100644 --- a/l10n_it_riba/migrations/16.0.1.0.0/pre-migrate.py +++ b/l10n_it_riba/migrations/16.0.1.0.0/pre-migrate.py @@ -1,9 +1,24 @@ # Copyright 2023 Simone Rubino - AionTech +# Copyright 2024 Nextev Srl # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from openupgradelib import openupgrade + from . import hooks def migrate(cr, installed_version): # Used by OpenUpgrade when module is in `apriori` hooks.migrate_old_module(cr) + + # copy old riba.distinta.line.state refs + openupgrade.copy_columns( + cr, + {"riba_distinta_line": [("state", None, None)]}, + ) + + # copy old riba.distinta.state refs + openupgrade.copy_columns( + cr, + {"riba_distinta": [("state", None, None)]}, + ) diff --git a/requirements.txt b/requirements.txt index 4d93246995fc..7052f10569c4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,5 +3,6 @@ asn1crypto codicefiscale elementpath mock +openupgradelib unidecode xmlschema