Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] patch tables for setup_models() #405

Merged
merged 3 commits into from
Nov 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions openerp/modules/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from .. import SUPERUSER_ID
from openerp.tools import assertion_report, lazy_property, classproperty, config, topological_sort
from openerp.tools.lru import LRU
from openerp.openupgrade import openupgrade_loading_90

_logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -65,6 +66,9 @@ def __init__(self, db_name):
if openerp.tools.config['unaccent'] and not has_unaccent:
_logger.warning("The option --unaccent was given but no unaccent() function was found in database.")
self.has_unaccent = openerp.tools.config['unaccent'] and has_unaccent

#OpenUpgrade: ir_model must be in 9.0 format before continuing
openupgrade_loading_90.migrate_model_tables(cr)
cr.close()

#
Expand Down
54 changes: 54 additions & 0 deletions openerp/openupgrade/openupgrade_loading_90.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright (C) 2010 - 2014 Savoir-faire Linux
# (<http://www.savoirfairelinux.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

# This module provides simple tools for OpenUpgrade migration, specific for
# the 8.0 -> 9.0 migration. It is kept in later editions to keep all the API
# docs in the latest release.


def migrate_model_tables(cr):
cr.execute("""SELECT 1 FROM information_schema.columns
WHERE table_name='ir_model' AND column_name='transient'
""")
found = cr.fetchone()
if not found:
# ir_model needs to be updated
cr.execute("""ALTER TABLE ir_model
ADD COLUMN transient boolean
""")

# we assume ir_model_fields needs fixing too
cr.execute("""ALTER TABLE ir_model_fields
ADD COLUMN help varchar,
ADD COLUMN index boolean,
ADD COLUMN copy boolean,
ADD COLUMN related varchar,
ADD COLUMN relation_table varchar,
ADD COLUMN column1 varchar,
ADD COLUMN column2 varchar,
ALTER COLUMN select_level SET DEFAULT '0'
""")

# ir_model needs to be updated
cr.execute("""ALTER TABLE ir_model_constraint
ADD COLUMN definition varchar
""")