Browse Source
Merge pull request #1441 from Tecnativa/10.0-base_exception-openupgrade_fix
[FIX] base_exception: Migration scripts
pull/1410/head
Pedro M. Baeza
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
19 additions and
13 deletions
-
base_exception/__init__.py
-
base_exception/__manifest__.py
-
base_exception/hooks.py
-
base_exception/migrations/10.0.1.0.0/pre-migration.py
|
|
@ -1,5 +1,5 @@ |
|
|
|
# -*- coding: utf-8 -*- |
|
|
|
# © 2011 Raphaël Valyi, Renato Lima, Guewen Baconnier, Sodexis |
|
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|
|
|
|
|
|
|
from . import wizard, models |
|
|
|
from .hooks import pre_init_hook |
|
|
@ -18,4 +18,5 @@ |
|
|
|
'views/base_exception_view.xml', |
|
|
|
], |
|
|
|
'installable': True, |
|
|
|
'pre_init_hook': 'pre_init_hook', |
|
|
|
} |
|
|
@ -0,0 +1,17 @@ |
|
|
|
# -*- coding: utf-8 -*- |
|
|
|
# Copyright 2017 Akretion, Mourad EL HADJ MIMOUNE |
|
|
|
# Copyright 2018 Tecnativa - Pedro M. Baeza |
|
|
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). |
|
|
|
|
|
|
|
|
|
|
|
def pre_init_hook(cr): |
|
|
|
"""If coming from v9 where only `sale_exception` is installed, when |
|
|
|
auto-installing this one by dependencies, we should take care of |
|
|
|
renaming previous table before the new model is loaded. |
|
|
|
""" |
|
|
|
cr.execute("SELECT 1 FROM pg_class WHERE relname = 'sale_exception'") |
|
|
|
if not cr.fetchone(): |
|
|
|
return # fresh install, so exiting |
|
|
|
from openupgradelib import openupgrade |
|
|
|
openupgrade.rename_tables(cr, [('sale_exception', 'exception_rule')]) |
|
|
|
openupgrade.rename_models(cr, [('sale.exception', 'exception.rule')]) |
|
|
@ -1,12 +0,0 @@ |
|
|
|
# -*- coding: utf-8 -*- |
|
|
|
# © 2017 Akretion, Mourad EL HADJ MIMOUNE |
|
|
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). |
|
|
|
|
|
|
|
from openupgradelib import openupgrade |
|
|
|
|
|
|
|
|
|
|
|
@openupgrade.migrate(use_env=True) |
|
|
|
def migrate(env, version): |
|
|
|
cr = env.cr |
|
|
|
openupgrade.rename_tables(cr, [('sale_exception', 'exception_rule')]) |
|
|
|
openupgrade.rename_models(cr, [('sale.exception', 'exception.rule')]) |