From 129e0b8ac7a67da248bef3fbe552c695f036844f Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Sun, 11 Dec 2016 20:00:12 +0100 Subject: [PATCH] [IMP] web_tree_many2one_clickable: Migration script from version 8 --- .../migrations/9.0.1.0.0/pre-migration.py | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 web_tree_many2one_clickable/migrations/9.0.1.0.0/pre-migration.py diff --git a/web_tree_many2one_clickable/migrations/9.0.1.0.0/pre-migration.py b/web_tree_many2one_clickable/migrations/9.0.1.0.0/pre-migration.py new file mode 100644 index 00000000..3a49bc01 --- /dev/null +++ b/web_tree_many2one_clickable/migrations/9.0.1.0.0/pre-migration.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# Copyright 2016 Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from openupgradelib import openupgrade + + +@openupgrade.migrate(use_env=True) +def migrate(env, version): + """If the system parameter exists before (manually created), don't error + on duplicated record inserting manually the XML-ID entry before the + loading. + """ + param = env['ir.config_parameter'].search([ + ('key', '=', 'web_tree_many2one_clickable.default') + ]) + if not param: + return + try: + env.ref('web_tree_many2one_clickable.default') + # XML-ID already exists - Nothing to do + except ValueError: + # Entry doesn't exist - Create it + env['ir.model.data'].create({ + 'module': 'web_tree_many2one_clickable', + 'name': 'default', + 'model': 'ir.config_parameter', + 'noupdate': True, + 'res_id': param.id, + })