From 76f333ed279e3072ecb723a73f5841c3225db005 Mon Sep 17 00:00:00 2001 From: cubells Date: Mon, 28 Nov 2016 09:59:09 +0100 Subject: [PATCH 01/13] [MIG] hr_recruitment module migration script * Added analisys * Created pre and post files --- .../migrations/9.0.1.0/noupdate_changes.xml | 18 +++ .../9.0.1.0/openupgrade_analysis_work.txt | 113 ++++++++++++++++++ .../migrations/9.0.1.0/post-migration.py | 16 +++ .../migrations/9.0.1.0/pre-migration.py | 13 ++ 4 files changed, 160 insertions(+) create mode 100644 addons/hr_recruitment/migrations/9.0.1.0/noupdate_changes.xml create mode 100644 addons/hr_recruitment/migrations/9.0.1.0/openupgrade_analysis_work.txt create mode 100644 addons/hr_recruitment/migrations/9.0.1.0/post-migration.py create mode 100644 addons/hr_recruitment/migrations/9.0.1.0/pre-migration.py diff --git a/addons/hr_recruitment/migrations/9.0.1.0/noupdate_changes.xml b/addons/hr_recruitment/migrations/9.0.1.0/noupdate_changes.xml new file mode 100644 index 000000000000..58a21509b8bb --- /dev/null +++ b/addons/hr_recruitment/migrations/9.0.1.0/noupdate_changes.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + mail.channel + + notification + + + + diff --git a/addons/hr_recruitment/migrations/9.0.1.0/openupgrade_analysis_work.txt b/addons/hr_recruitment/migrations/9.0.1.0/openupgrade_analysis_work.txt new file mode 100644 index 000000000000..1b20ee648f2a --- /dev/null +++ b/addons/hr_recruitment/migrations/9.0.1.0/openupgrade_analysis_work.txt @@ -0,0 +1,113 @@ +---Fields in module 'hr_recruitment'--- +hr_recruitment / hr.applicant / attachment_ids (one2many) : NEW relation: ir.attachment +# Nothing to do + +hr_recruitment / hr.applicant / availability (integer) : type is now 'date' ('integer') +# Unable to calculate date form a integer --> Nothing to do + +hr_recruitment / hr.applicant / campaign_id (many2one) : NEW relation: utm.campaign +# Nothing to do + +hr_recruitment / hr.applicant / categ_ids (many2many) : relation is now 'hr.applicant.category' ('hr.applicant_category') +# Nothing to do + +hr_recruitment / hr.applicant / medium_id (many2one) : NEW relation: utm.medium +# Nothing to do + +hr_recruitment / hr.applicant / message_follower_ids (many2many): not a function anymore +hr_recruitment / hr.applicant / message_follower_ids (many2many): relation is now 'mail.followers' ('res.partner') +hr_recruitment / hr.applicant / message_follower_ids (many2many): type is now 'one2many' ('many2many') +# Concerns module Mail (has to be done in another migration script specifically for that module) ---> Nothing to do + +hr_recruitment / hr.applicant / priority (selection) : selection_keys is now '['0', '1', '2', '3']' ('['0', '1', '2', '3', '4']') +# Done: Adapt to new range + +hr_recruitment / hr.applicant / source_id (many2one) : relation is now 'utm.source' ('hr.recruitment.source') +# Nothing to do + +hr_recruitment / hr.applicant.category / name (char) : NEW required: required +# Nothing to do + +hr_recruitment / hr.job / stage_ids (many2many) : NEW relation: hr.recruitment.stage +# Nothing to do + +hr_recruitment / hr.recruitment.source / _inherits (False) : NEW +# Nothing to do + +hr_recruitment / hr.recruitment.source / alias_id (many2one) : NEW relation: mail.alias +# Nothing to do + +hr_recruitment / hr.recruitment.source / job_id (many2one) : NEW relation: hr.job +# Nothing to do + +hr_recruitment / hr.recruitment.source / name (char) : DEL required: required +hr_recruitment / hr.recruitment.source / source_id (many2one) : NEW relation: utm.source, required: required +# Nothing to do + +hr_recruitment / hr.recruitment.stage / department_id (many2one) : DEL relation: hr.department +hr_recruitment / hr.recruitment.stage / job_ids (many2many) : NEW relation: hr.job +# Nothing to do + +hr_recruitment / hr.recruitment.stage / template_id (many2one) : relation is now 'mail.template' ('email.template') +# Nothing to do + + +---XML records in module 'hr_recruitment'--- +DEL email.template: hr_recruitment.applicant_interest +DEL email.template: hr_recruitment.applicant_refuse +NEW hr.applicant.category: hr_recruitment.tag_applicant_it +NEW hr.applicant.category: hr_recruitment.tag_applicant_manager +NEW hr.applicant.category: hr_recruitment.tag_applicant_reserve +NEW hr.applicant.category: hr_recruitment.tag_applicant_sales +DEL hr.applicant_category: hr_recruitment.tag_applicant_it +DEL hr.applicant_category: hr_recruitment.tag_applicant_manager +DEL hr.applicant_category: hr_recruitment.tag_applicant_reserve +DEL hr.applicant_category: hr_recruitment.tag_applicant_sales +DEL hr.recruitment.source: hr_recruitment.source_linkedin +DEL hr.recruitment.source: hr_recruitment.source_monster +DEL hr.recruitment.source: hr_recruitment.source_website_company +DEL hr.recruitment.source: hr_recruitment.source_word +DEL hr.recruitment.stage: hr_recruitment.stage_job1 +DEL hr.recruitment.stage: hr_recruitment.stage_job2 +DEL hr.recruitment.stage: hr_recruitment.stage_job3 +DEL hr.recruitment.stage: hr_recruitment.stage_job4 +DEL hr.recruitment.stage: hr_recruitment.stage_job5 +DEL hr.recruitment.stage: hr_recruitment.stage_job6 +NEW ir.actions.act_window: hr_recruitment.action_hr_job_config +NEW ir.actions.act_window: hr_recruitment.action_hr_job_new_application +NEW ir.actions.act_window: hr_recruitment.action_hr_job_no_employee +NEW ir.actions.act_window: hr_recruitment.action_hr_job_sources +NEW ir.actions.act_window: hr_recruitment.action_hr_recruitment_configuration +NEW ir.actions.act_window: hr_recruitment.action_hr_recruitment_report_filtered_department +NEW ir.actions.act_window: hr_recruitment.action_hr_recruitment_report_filtered_job +NEW ir.actions.act_window: hr_recruitment.hr_applicant_action_from_department +NEW ir.actions.act_window: hr_recruitment.hr_applicant_resumes +NEW ir.actions.act_window: hr_recruitment.hr_employee_action_from_department +DEL ir.actions.act_window: hr_recruitment.act_hr_applicant_to_meeting +DEL ir.actions.act_window: hr_recruitment.action_hr_recruitment_partner_create +DEL ir.actions.act_window: hr_recruitment.hr_recruitment_stage_form_installer +NEW ir.actions.client: hr_recruitment.action_client_hr_recruitment_menu +NEW ir.ui.menu: hr.menu_hr_job_position_config +NEW ir.ui.menu: hr_recruitment.menu_crm_case_categ0_act_job02 +NEW ir.ui.menu: hr_recruitment.menu_hr_recruitment_configuration +NEW ir.ui.menu: hr_recruitment.menu_hr_recruitment_global_settings +NEW ir.ui.menu: hr_recruitment.menu_hr_recruitment_root +NEW ir.ui.menu: hr_recruitment.report_hr_recruitment +DEL ir.ui.menu: base.menu_crm_case_job_req_main +DEL ir.ui.menu: hr_recruitment.menu_hr_recruitment_recruitment +DEL ir.ui.menu: hr_recruitment.menu_hr_recruitment_report_all +NEW ir.ui.view: hr_recruitment.crm_case_pivot_view_job +NEW ir.ui.view: hr_recruitment.hr_department_view_kanban +NEW ir.ui.view: hr_recruitment.hr_employee_view_search +NEW ir.ui.view: hr_recruitment.view_hr_recruitment_configuration +NEW ir.ui.view: hr_recruitment.view_hr_recruitment_report_pivot +DEL ir.ui.view: hr_recruitment.hr_recruitment_source_form +DEL ir.ui.view: hr_recruitment.view_hr_apll_config_settings +DEL ir.ui.view: hr_recruitment.view_hr_recruitment_partner_create +NEW mail.message.subtype: hr_recruitment.mt_department_new +NEW mail.message.subtype: hr_recruitment.mt_job_new +DEL mail.message.subtype: hr_recruitment.mt_job_applicant_new +NEW mail.template: hr_recruitment.applicant_interest +NEW mail.template: hr_recruitment.applicant_refuse +NEW mail.template: hr_recruitment.hr_welcome_new_employee +NEW utm.campaign: hr_recruitment.utm_campaign_job diff --git a/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py b/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py new file mode 100644 index 000000000000..c11cc96a6c67 --- /dev/null +++ b/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# © 2016 Tecnativa +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from openupgradelib import openupgrade + + +@openupgrade.migrate() +def migrate(cr, version): + openupgrade.load_data(cr, 'survey', + 'migrations/9.0.1.0/noupdate_changes.xml') + openupgrade.map_values( + cr, + openupgrade.get_legacy_name('priority'), + 'priority', + [('4', '3'), ('3', '1'), ('2', '0'), ('1', '0')], + table='hr_applicant', write='sql') diff --git a/addons/hr_recruitment/migrations/9.0.1.0/pre-migration.py b/addons/hr_recruitment/migrations/9.0.1.0/pre-migration.py new file mode 100644 index 000000000000..1d4fb044a545 --- /dev/null +++ b/addons/hr_recruitment/migrations/9.0.1.0/pre-migration.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- +# © 2016 Tecnativa - Vicent Cubells +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from openupgradelib import openupgrade + + +column_renames = { + 'hr_applicant': [('priority', None)]} + + +@openupgrade.migrate() +def migrate(cr, version): + openupgrade.rename_columns(cr, column_renames) From d6d31ff38338dfba3ba76d29c862ebc44525bd2e Mon Sep 17 00:00:00 2001 From: cubells Date: Mon, 28 Nov 2016 15:05:38 +0100 Subject: [PATCH 02/13] Updated module coverage document --- openerp/openupgrade/doc/source/modules80-90.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openerp/openupgrade/doc/source/modules80-90.rst b/openerp/openupgrade/doc/source/modules80-90.rst index d7e19dbd5e62..89af201424e7 100644 --- a/openerp/openupgrade/doc/source/modules80-90.rst +++ b/openerp/openupgrade/doc/source/modules80-90.rst @@ -134,7 +134,7 @@ Status : +-----------------------------------+-----------------------------------+ |hr_payroll_account | Done | +-----------------------------------+-----------------------------------+ -|hr_recruitment | | +|hr_recruitment | Done | +-----------------------------------+-----------------------------------+ |hr_timesheet | Done | +-----------------------------------+-----------------------------------+ From 04c6d893318982ec3370e33b8880278034bd63dc Mon Sep 17 00:00:00 2001 From: cubells Date: Tue, 29 Nov 2016 17:40:34 +0100 Subject: [PATCH 03/13] Updated availability and source_id of hr.applicant --- .../9.0.1.0/openupgrade_analysis_work.txt | 4 ++-- .../migrations/9.0.1.0/post-migration.py | 22 +++++++++++++++++ .../migrations/9.0.1.0/pre-migration.py | 24 ++++++++++++++++++- 3 files changed, 47 insertions(+), 3 deletions(-) diff --git a/addons/hr_recruitment/migrations/9.0.1.0/openupgrade_analysis_work.txt b/addons/hr_recruitment/migrations/9.0.1.0/openupgrade_analysis_work.txt index 1b20ee648f2a..c0b26ac06121 100644 --- a/addons/hr_recruitment/migrations/9.0.1.0/openupgrade_analysis_work.txt +++ b/addons/hr_recruitment/migrations/9.0.1.0/openupgrade_analysis_work.txt @@ -3,7 +3,7 @@ hr_recruitment / hr.applicant / attachment_ids (one2many) : NEW # Nothing to do hr_recruitment / hr.applicant / availability (integer) : type is now 'date' ('integer') -# Unable to calculate date form a integer --> Nothing to do +# Done: calculated availability with create_date + availability days hr_recruitment / hr.applicant / campaign_id (many2one) : NEW relation: utm.campaign # Nothing to do @@ -23,7 +23,7 @@ hr_recruitment / hr.applicant / priority (selection) : sele # Done: Adapt to new range hr_recruitment / hr.applicant / source_id (many2one) : relation is now 'utm.source' ('hr.recruitment.source') -# Nothing to do +# Done: created new utm.source from source_id and updated records hr_recruitment / hr.applicant.category / name (char) : NEW required: required # Nothing to do diff --git a/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py b/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py index c11cc96a6c67..8a7536eb51e9 100644 --- a/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py +++ b/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py @@ -2,6 +2,27 @@ # © 2016 Tecnativa # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from openupgradelib import openupgrade +from openerp import fields +from datetime import timedelta + + +def update_applicant_availability(cr): + cr.execute( + """ + SELECT id, create_date, %s + FROM hr_applicant + """ % (openupgrade.get_legacy_name('availability'),) + ) + for applicant in cr.fetchall(): + new_date = fields.Date.from_string(applicant[1]) + if applicant[2]: + new_date += timedelta(days=applicant[2]) + openupgrade.logged_query( + cr, + """ + UPDATE hr_applicant SET availability = %s + WHERE id = %s + """ % (new_date, applicant[0])) @openupgrade.migrate() @@ -14,3 +35,4 @@ def migrate(cr, version): 'priority', [('4', '3'), ('3', '1'), ('2', '0'), ('1', '0')], table='hr_applicant', write='sql') + update_applicant_availability(cr) diff --git a/addons/hr_recruitment/migrations/9.0.1.0/pre-migration.py b/addons/hr_recruitment/migrations/9.0.1.0/pre-migration.py index 1d4fb044a545..d49a62851492 100644 --- a/addons/hr_recruitment/migrations/9.0.1.0/pre-migration.py +++ b/addons/hr_recruitment/migrations/9.0.1.0/pre-migration.py @@ -5,9 +5,31 @@ column_renames = { - 'hr_applicant': [('priority', None)]} + 'hr_applicant': [ + ('priority', None), + ('availability', None), + ]} + + +def migrate_applicant_source(cr): + cr.execute( + """ + SELECT id + FROM hr_recruitment_source + """) + for old_id in cr.fetchall(): + cr.execute("INSERT_INTO utm_source (name) " + "SELECT name " + "FROM hr_recruitment_source " + "RETURNING id") + new_id = cr.fetchone()[0] + cr.execute("UPDATE hr_applicant " + "SET source_id = %s " + "WHERE source_id = %s", + (new_id, old_id[0])) @openupgrade.migrate() def migrate(cr, version): openupgrade.rename_columns(cr, column_renames) + migrate_applicant_source(cr) From 92cc0f5d6ec8ac3147f9664054d5144e192b8b7d Mon Sep 17 00:00:00 2001 From: cubells Date: Wed, 30 Nov 2016 07:06:57 +0100 Subject: [PATCH 04/13] FIX move update source to post-migration --- .../migrations/9.0.1.0/post-migration.py | 20 +++++++++++++++++++ .../migrations/9.0.1.0/pre-migration.py | 19 ------------------ 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py b/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py index 8a7536eb51e9..b75060e67d0f 100644 --- a/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py +++ b/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py @@ -17,6 +17,7 @@ def update_applicant_availability(cr): new_date = fields.Date.from_string(applicant[1]) if applicant[2]: new_date += timedelta(days=applicant[2]) + new_date = fields.Date.to_string(new_date) openupgrade.logged_query( cr, """ @@ -25,6 +26,24 @@ def update_applicant_availability(cr): """ % (new_date, applicant[0])) +def migrate_applicant_source(cr): + cr.execute( + """ + SELECT id + FROM hr_recruitment_source + """) + for old_id in cr.fetchall(): + cr.execute("INSERT_INTO utm_source (name) " + "SELECT name " + "FROM hr_recruitment_source " + "RETURNING id") + new_id = cr.fetchone()[0] + cr.execute("UPDATE hr_applicant " + "SET source_id = %s " + "WHERE source_id = %s", + (new_id, old_id[0])) + + @openupgrade.migrate() def migrate(cr, version): openupgrade.load_data(cr, 'survey', @@ -36,3 +55,4 @@ def migrate(cr, version): [('4', '3'), ('3', '1'), ('2', '0'), ('1', '0')], table='hr_applicant', write='sql') update_applicant_availability(cr) + migrate_applicant_source(cr) diff --git a/addons/hr_recruitment/migrations/9.0.1.0/pre-migration.py b/addons/hr_recruitment/migrations/9.0.1.0/pre-migration.py index d49a62851492..9f8cc132b376 100644 --- a/addons/hr_recruitment/migrations/9.0.1.0/pre-migration.py +++ b/addons/hr_recruitment/migrations/9.0.1.0/pre-migration.py @@ -11,25 +11,6 @@ ]} -def migrate_applicant_source(cr): - cr.execute( - """ - SELECT id - FROM hr_recruitment_source - """) - for old_id in cr.fetchall(): - cr.execute("INSERT_INTO utm_source (name) " - "SELECT name " - "FROM hr_recruitment_source " - "RETURNING id") - new_id = cr.fetchone()[0] - cr.execute("UPDATE hr_applicant " - "SET source_id = %s " - "WHERE source_id = %s", - (new_id, old_id[0])) - - @openupgrade.migrate() def migrate(cr, version): openupgrade.rename_columns(cr, column_renames) - migrate_applicant_source(cr) From 28ad0d25a9fd866706c7c8685bb218c9b187f9a8 Mon Sep 17 00:00:00 2001 From: cubells Date: Wed, 30 Nov 2016 08:01:42 +0100 Subject: [PATCH 05/13] FIX typo in post-migration script --- addons/hr_recruitment/migrations/9.0.1.0/post-migration.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py b/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py index b75060e67d0f..719cf1fd2554 100644 --- a/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py +++ b/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py @@ -46,7 +46,7 @@ def migrate_applicant_source(cr): @openupgrade.migrate() def migrate(cr, version): - openupgrade.load_data(cr, 'survey', + openupgrade.load_data(cr, 'hr_recruitment', 'migrations/9.0.1.0/noupdate_changes.xml') openupgrade.map_values( cr, From 033d4cf79fa5af868c50980b80681794f35770ce Mon Sep 17 00:00:00 2001 From: cubells Date: Wed, 30 Nov 2016 08:28:12 +0100 Subject: [PATCH 06/13] FIX reverted mapping in post-migration script --- addons/hr_recruitment/migrations/9.0.1.0/post-migration.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py b/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py index 719cf1fd2554..2282e656651d 100644 --- a/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py +++ b/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py @@ -52,7 +52,7 @@ def migrate(cr, version): cr, openupgrade.get_legacy_name('priority'), 'priority', - [('4', '3'), ('3', '1'), ('2', '0'), ('1', '0')], + [('1', '0'), ('2', '0'), ('3', '1'), ('4', '3')], table='hr_applicant', write='sql') update_applicant_availability(cr) migrate_applicant_source(cr) From 0fbaa58b4913930e4311c80f56ecb88c84a5bf71 Mon Sep 17 00:00:00 2001 From: cubells Date: Wed, 30 Nov 2016 08:37:50 +0100 Subject: [PATCH 07/13] FIX incorrect query in post-migration script --- addons/hr_recruitment/migrations/9.0.1.0/post-migration.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py b/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py index 2282e656651d..817cd12952a5 100644 --- a/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py +++ b/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py @@ -22,7 +22,7 @@ def update_applicant_availability(cr): cr, """ UPDATE hr_applicant SET availability = %s - WHERE id = %s + WHERE id = '%s' """ % (new_date, applicant[0])) From 09a90d29430e9300ef5ff4b93776e361fe19aa57 Mon Sep 17 00:00:00 2001 From: cubells Date: Wed, 30 Nov 2016 08:41:51 +0100 Subject: [PATCH 08/13] FIX incorrect query in post-migration script --- addons/hr_recruitment/migrations/9.0.1.0/post-migration.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py b/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py index 817cd12952a5..6f872b5e178b 100644 --- a/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py +++ b/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py @@ -22,8 +22,8 @@ def update_applicant_availability(cr): cr, """ UPDATE hr_applicant SET availability = %s - WHERE id = '%s' - """ % (new_date, applicant[0])) + WHERE id = %s + """, (new_date, applicant[0])) def migrate_applicant_source(cr): From b5359c771bfa9ab623ae7090d05ac0d8204fdf0a Mon Sep 17 00:00:00 2001 From: cubells Date: Wed, 30 Nov 2016 09:05:44 +0100 Subject: [PATCH 09/13] FIX typo in post-migration script --- addons/hr_recruitment/migrations/9.0.1.0/post-migration.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py b/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py index 6f872b5e178b..819f7c14769a 100644 --- a/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py +++ b/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py @@ -33,7 +33,7 @@ def migrate_applicant_source(cr): FROM hr_recruitment_source """) for old_id in cr.fetchall(): - cr.execute("INSERT_INTO utm_source (name) " + cr.execute("INSERT INTO utm_source (name) " "SELECT name " "FROM hr_recruitment_source " "RETURNING id") From 21ed74827e4fefe1b31019d7ee71157e27e5a4a8 Mon Sep 17 00:00:00 2001 From: cubells Date: Wed, 30 Nov 2016 15:50:00 +0100 Subject: [PATCH 10/13] FIX: rename table hr_recruitment_source to preserve data --- addons/hr_recruitment/migrations/9.0.1.0/pre-migration.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/addons/hr_recruitment/migrations/9.0.1.0/pre-migration.py b/addons/hr_recruitment/migrations/9.0.1.0/pre-migration.py index 9f8cc132b376..05c64d69d5ff 100644 --- a/addons/hr_recruitment/migrations/9.0.1.0/pre-migration.py +++ b/addons/hr_recruitment/migrations/9.0.1.0/pre-migration.py @@ -10,7 +10,12 @@ ('availability', None), ]} +table_renames = [ + ('hr_recruitment_source', None), +] + @openupgrade.migrate() def migrate(cr, version): openupgrade.rename_columns(cr, column_renames) + openupgrade.rename_tables(cr, table_renames) \ No newline at end of file From 5cace179abcd628297ea87149ddd548b3e14c782 Mon Sep 17 00:00:00 2001 From: cubells Date: Wed, 7 Dec 2016 08:30:10 +0100 Subject: [PATCH 11/13] Incorrect insert into query --- addons/hr_recruitment/migrations/9.0.1.0/post-migration.py | 7 ++++--- addons/hr_recruitment/migrations/9.0.1.0/pre-migration.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py b/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py index 819f7c14769a..0ac249c45902 100644 --- a/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py +++ b/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py @@ -11,7 +11,7 @@ def update_applicant_availability(cr): """ SELECT id, create_date, %s FROM hr_applicant - """ % (openupgrade.get_legacy_name('availability'),) + """, (openupgrade.get_legacy_name('availability'),) ) for applicant in cr.fetchall(): new_date = fields.Date.from_string(applicant[1]) @@ -35,8 +35,9 @@ def migrate_applicant_source(cr): for old_id in cr.fetchall(): cr.execute("INSERT INTO utm_source (name) " "SELECT name " - "FROM hr_recruitment_source " - "RETURNING id") + "FROM %s " + "RETURNING id", + (openupgrade.get_legacy_name('hr_recruitment_source'),)) new_id = cr.fetchone()[0] cr.execute("UPDATE hr_applicant " "SET source_id = %s " diff --git a/addons/hr_recruitment/migrations/9.0.1.0/pre-migration.py b/addons/hr_recruitment/migrations/9.0.1.0/pre-migration.py index 05c64d69d5ff..b2c53a895e30 100644 --- a/addons/hr_recruitment/migrations/9.0.1.0/pre-migration.py +++ b/addons/hr_recruitment/migrations/9.0.1.0/pre-migration.py @@ -18,4 +18,4 @@ @openupgrade.migrate() def migrate(cr, version): openupgrade.rename_columns(cr, column_renames) - openupgrade.rename_tables(cr, table_renames) \ No newline at end of file + openupgrade.rename_tables(cr, table_renames) From 4fe2318fdb720cb15200f451ec0a976c7d583faf Mon Sep 17 00:00:00 2001 From: cubells Date: Wed, 7 Dec 2016 08:40:22 +0100 Subject: [PATCH 12/13] Incorrect type on query --- addons/hr_recruitment/migrations/9.0.1.0/post-migration.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py b/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py index 0ac249c45902..ee6ac15e40ef 100644 --- a/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py +++ b/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py @@ -16,7 +16,7 @@ def update_applicant_availability(cr): for applicant in cr.fetchall(): new_date = fields.Date.from_string(applicant[1]) if applicant[2]: - new_date += timedelta(days=applicant[2]) + new_date += timedelta(days=int(applicant[2])) new_date = fields.Date.to_string(new_date) openupgrade.logged_query( cr, From 78f293dcf7e98e054174522104f1ebe1470c9fe5 Mon Sep 17 00:00:00 2001 From: cubells Date: Wed, 7 Dec 2016 09:02:50 +0100 Subject: [PATCH 13/13] Incorrect type on query --- addons/hr_recruitment/migrations/9.0.1.0/post-migration.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py b/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py index ee6ac15e40ef..644c5aaae55f 100644 --- a/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py +++ b/addons/hr_recruitment/migrations/9.0.1.0/post-migration.py @@ -11,7 +11,7 @@ def update_applicant_availability(cr): """ SELECT id, create_date, %s FROM hr_applicant - """, (openupgrade.get_legacy_name('availability'),) + """ % (openupgrade.get_legacy_name('availability'),) ) for applicant in cr.fetchall(): new_date = fields.Date.from_string(applicant[1])