-
-
Notifications
You must be signed in to change notification settings - Fork 820
[MIG] hr_recruitment module migration script #682
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
76f333e
[MIG] hr_recruitment module migration script
cubells d6d31ff
Updated module coverage document
cubells 04c6d89
Updated availability and source_id of hr.applicant
cubells 92cc0f5
FIX move update source to post-migration
cubells 28ad0d2
FIX typo in post-migration script
cubells 033d4cf
FIX reverted mapping in post-migration script
cubells 0fbaa58
FIX incorrect query in post-migration script
cubells 09a90d2
FIX incorrect query in post-migration script
cubells b5359c7
FIX typo in post-migration script
cubells 21ed748
FIX: rename table hr_recruitment_source to preserve data
cubells 5cace17
Incorrect insert into query
cubells 4fe2318
Incorrect type on query
cubells 78f293d
Incorrect type on query
cubells File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
addons/hr_recruitment/migrations/9.0.1.0/noupdate_changes.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| <?xml version='1.0' encoding='utf-8'?> | ||
| <openerp> | ||
| <data> | ||
| <record id="mt_job_applicant_stage_changed" model="mail.message.subtype"><field name="default" eval="False"/> | ||
| </record> | ||
| <record id="base.open_menu" model="ir.actions.todo"><field name="action_id" ref="action_client_hr_recruitment_menu"/> | ||
| </record> | ||
| <record id="mt_applicant_hired" model="mail.message.subtype"><field name="default" eval="True"/> | ||
| </record> | ||
| <record id="mt_applicant_new" model="mail.message.subtype"><field name="hidden" eval="True"/> | ||
| </record> | ||
| <record id="module_install_notification" model="mail.message"><field name="type"/><field name="model">mail.channel</field> | ||
| <field name="res_id" ref="mail.channel_all_employees"/> | ||
| <field name="message_type">notification</field> | ||
| </record> | ||
| </data> | ||
| </openerp> | ||
|
|
||
113 changes: 113 additions & 0 deletions
113
addons/hr_recruitment/migrations/9.0.1.0/openupgrade_analysis_work.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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') | ||
| # Done: calculated availability with create_date + availability days | ||
|
|
||
| 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') | ||
| # Done: created new utm.source from source_id and updated records | ||
|
|
||
| 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 |
59 changes: 59 additions & 0 deletions
59
addons/hr_recruitment/migrations/9.0.1.0/post-migration.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| # -*- coding: utf-8 -*- | ||
| # © 2016 Tecnativa <vicent.cubells@tecnativa.com> | ||
| # 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=int(applicant[2])) | ||
| new_date = fields.Date.to_string(new_date) | ||
| openupgrade.logged_query( | ||
| cr, | ||
| """ | ||
| UPDATE hr_applicant SET availability = %s | ||
| WHERE id = %s | ||
| """, (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 %s " | ||
| "RETURNING id", | ||
| (openupgrade.get_legacy_name('hr_recruitment_source'),)) | ||
| 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, 'hr_recruitment', | ||
| 'migrations/9.0.1.0/noupdate_changes.xml') | ||
| openupgrade.map_values( | ||
| cr, | ||
| openupgrade.get_legacy_name('priority'), | ||
| 'priority', | ||
| [('1', '0'), ('2', '0'), ('3', '1'), ('4', '3')], | ||
| table='hr_applicant', write='sql') | ||
| update_applicant_availability(cr) | ||
| migrate_applicant_source(cr) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # -*- coding: utf-8 -*- | ||
| # © 2016 Tecnativa - Vicent Cubells <vicent.cubells@tecnativa.com> | ||
| # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
| from openupgradelib import openupgrade | ||
|
|
||
|
|
||
| column_renames = { | ||
| 'hr_applicant': [ | ||
| ('priority', None), | ||
| ('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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove labels openerp data by odoo in v9.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an automatic file generated by https://github.com/OCA/OpenUpgrade/blob/9.0/scripts/compare_noupdate_xml_records.py, so we can leave it as is for this version and change the script for next one.