From 0ab024a2e1a087150fac41fa5394384cbdd21011 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Wed, 1 Dec 2021 09:56:16 +0100 Subject: [PATCH] [OU-FIX] account_payment_mode: Rename xmlids According to the renaming of the addon `account_payment` from odoo to `account_payment_order`, the rule "payment_mode_comp_rule" (of `account_payment`) must be renamed and linked to the addon `account_payment_mode` to avoid creating a new rule. TT33065 --- account_payment_mode/hooks.py | 13 ++++++++++++- .../migrations/9.0.1.0.0/noupdate_changes.xml | 7 +++++++ .../migrations/9.0.1.0.0/post-migration.py | 3 +++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 account_payment_mode/migrations/9.0.1.0.0/noupdate_changes.xml diff --git a/account_payment_mode/hooks.py b/account_payment_mode/hooks.py index 6fb581980..10a8a6228 100644 --- a/account_payment_mode/hooks.py +++ b/account_payment_mode/hooks.py @@ -7,6 +7,14 @@ def pre_init_hook(cr): migrate_from_8(cr) +xmlid_renames = [ + ( + "account_payment_order.payment_mode_comp_rule", + "account_payment_mode.account_payment_mode_company_rule", + ) +] + + def migrate_from_8(cr): """If we're installed on a database which has the payment_mode table from 8.0, move its table so that we use the already existing modes""" @@ -14,9 +22,12 @@ def migrate_from_8(cr): if not cr.fetchone(): return try: - from openupgradelib.openupgrade import rename_models, rename_tables + from openupgradelib.openupgrade import ( + rename_models, rename_tables, rename_xmlids + ) rename_models(cr, [('payment.mode', 'account.payment.mode')]) rename_tables(cr, [('payment_mode', 'account_payment_mode')]) + rename_xmlids(cr, xmlid_renames) except ImportError: cr.execute('ALTER TABLE payment_mode RENAME TO account_payment_mode') cr.execute('ALTER SEQUENCE payment_mode_id_seq ' diff --git a/account_payment_mode/migrations/9.0.1.0.0/noupdate_changes.xml b/account_payment_mode/migrations/9.0.1.0.0/noupdate_changes.xml new file mode 100644 index 000000000..5e0be6b47 --- /dev/null +++ b/account_payment_mode/migrations/9.0.1.0.0/noupdate_changes.xml @@ -0,0 +1,7 @@ + + + + Payment mode multi-company rule + + + diff --git a/account_payment_mode/migrations/9.0.1.0.0/post-migration.py b/account_payment_mode/migrations/9.0.1.0.0/post-migration.py index 0e605831f..d3dc37dd6 100644 --- a/account_payment_mode/migrations/9.0.1.0.0/post-migration.py +++ b/account_payment_mode/migrations/9.0.1.0.0/post-migration.py @@ -22,3 +22,6 @@ def migrate(env, version): FROM account_payment_method pm WHERE apm.payment_method_id = pm.id WHERE payment_type IS NULL; """) + openupgrade.load_data( + env.cr, "account_payment_mode", "migrations/9.0.1.0.0/noupdate_changes.xml" + )