From a7095730909d8f5fcc32bd4aed09bb9e0e09e10f Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Mon, 17 Aug 2015 11:42:26 +0200 Subject: [PATCH 1/3] [FIX] migrate categories of hr.holiday.status --- .../migrations/7.0.1.5/post-migration.py | 41 +++++++++++++++++++ .../migrations/7.0.1.5/pre-migration.py | 1 + 2 files changed, 42 insertions(+) create mode 100644 addons/hr_holidays/migrations/7.0.1.5/post-migration.py diff --git a/addons/hr_holidays/migrations/7.0.1.5/post-migration.py b/addons/hr_holidays/migrations/7.0.1.5/post-migration.py new file mode 100644 index 000000000000..f85238c41334 --- /dev/null +++ b/addons/hr_holidays/migrations/7.0.1.5/post-migration.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This migration script copyright (C) 2015 Therp BV +# +# 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 . +# +############################################################################## +from openupgrade import openupgrade + + +@openupgrade.migrate() +def migrate(cr, version): + # write categories from crm.case.categ + cr.execute('alter table crm_meeting_type add column %s integer', + openupgrade.get_legacy_name('crm_meeting_type_id')) + cr.execute( + 'insert into crm_meeting_type (name, %s) ' + 'select name, id from crm_case_categ where object_id=' + "(select id from ir_model where model='crm.meeting')" % + openupgrade.get_legacy_name('crm_meeting_type_id')) + cr.execute( + 'update hr_holidays_status s ' + 'set categ_id=t.id ' + 'from crm_meeting_type t ' + 'where t.%s=s.%s' % ( + openupgrade.get_legacy_name('crm_meeting_type_id'), + openupgrade.get_legacy_name('categ_id'), + )) diff --git a/addons/hr_holidays/migrations/7.0.1.5/pre-migration.py b/addons/hr_holidays/migrations/7.0.1.5/pre-migration.py index 151faf0e06b5..9e406d724cec 100644 --- a/addons/hr_holidays/migrations/7.0.1.5/pre-migration.py +++ b/addons/hr_holidays/migrations/7.0.1.5/pre-migration.py @@ -24,6 +24,7 @@ column_renames = { 'hr_holidays': [ ('case_id', 'meeting_id'), + ('categ_id', None), ] } From d893517820f5aed3739517d2274b754237600f89 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Mon, 17 Aug 2015 13:05:43 +0200 Subject: [PATCH 2/3] [FIX] syntax problems --- addons/hr_holidays/migrations/7.0.1.5/post-migration.py | 2 +- addons/hr_holidays/migrations/7.0.1.5/pre-migration.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/hr_holidays/migrations/7.0.1.5/post-migration.py b/addons/hr_holidays/migrations/7.0.1.5/post-migration.py index f85238c41334..4bac0afadd8c 100644 --- a/addons/hr_holidays/migrations/7.0.1.5/post-migration.py +++ b/addons/hr_holidays/migrations/7.0.1.5/post-migration.py @@ -24,7 +24,7 @@ @openupgrade.migrate() def migrate(cr, version): # write categories from crm.case.categ - cr.execute('alter table crm_meeting_type add column %s integer', + cr.execute('alter table crm_meeting_type add column %s integer' % openupgrade.get_legacy_name('crm_meeting_type_id')) cr.execute( 'insert into crm_meeting_type (name, %s) ' diff --git a/addons/hr_holidays/migrations/7.0.1.5/pre-migration.py b/addons/hr_holidays/migrations/7.0.1.5/pre-migration.py index 9e406d724cec..f64a726a9b5a 100644 --- a/addons/hr_holidays/migrations/7.0.1.5/pre-migration.py +++ b/addons/hr_holidays/migrations/7.0.1.5/pre-migration.py @@ -24,8 +24,10 @@ column_renames = { 'hr_holidays': [ ('case_id', 'meeting_id'), + ], + 'hr_holidays_status': [ ('categ_id', None), - ] + ], } From 3f26afc129f253a9eef564ab7c9d691c20094bf0 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Tue, 18 Aug 2015 14:59:13 +0200 Subject: [PATCH 3/3] [IMP] use better name for legacy column --- addons/hr_holidays/migrations/7.0.1.5/post-migration.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/hr_holidays/migrations/7.0.1.5/post-migration.py b/addons/hr_holidays/migrations/7.0.1.5/post-migration.py index 4bac0afadd8c..c08bf774ccc8 100644 --- a/addons/hr_holidays/migrations/7.0.1.5/post-migration.py +++ b/addons/hr_holidays/migrations/7.0.1.5/post-migration.py @@ -25,17 +25,17 @@ def migrate(cr, version): # write categories from crm.case.categ cr.execute('alter table crm_meeting_type add column %s integer' % - openupgrade.get_legacy_name('crm_meeting_type_id')) + openupgrade.get_legacy_name('crm_case_categ_id')) cr.execute( 'insert into crm_meeting_type (name, %s) ' 'select name, id from crm_case_categ where object_id=' "(select id from ir_model where model='crm.meeting')" % - openupgrade.get_legacy_name('crm_meeting_type_id')) + openupgrade.get_legacy_name('crm_case_categ_id')) cr.execute( 'update hr_holidays_status s ' 'set categ_id=t.id ' 'from crm_meeting_type t ' 'where t.%s=s.%s' % ( - openupgrade.get_legacy_name('crm_meeting_type_id'), + openupgrade.get_legacy_name('crm_case_categ_id'), openupgrade.get_legacy_name('categ_id'), ))