forked from tvtma/OpenUpgrade
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
94d12ec
commit e8819b3
Showing
4 changed files
with
171 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
14 changes: 14 additions & 0 deletions
14
openupgrade_scripts/scripts/project_todo/17.0.1.0/post_migration.py
This file contains 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,14 @@ | ||
# Copyright 2024 Viindoo Technology Joint Stock Company (Viindoo) | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from openupgradelib import openupgrade | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
# convert users from mail_followers -> user_ids | ||
# (new feature, users in user_ids can see to do tasks on kanban or list) | ||
# and fill missing personal stages (_populate_missing_personal_stages) | ||
todo_tasks = env["project.task"].search([("project_id", "=", False)]) | ||
for task in todo_tasks: | ||
task.user_ids = task.message_follower_ids.partner_id.user_id |
115 changes: 115 additions & 0 deletions
115
openupgrade_scripts/scripts/project_todo/17.0.1.0/pre-migration.py
This file contains 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,115 @@ | ||
# Copyright 2024 Viindoo Technology Joint Stock Company (Viindoo) | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from openupgradelib import openupgrade | ||
|
||
_rename_xmlids = [ | ||
( | ||
"note.mail_activity_data_reminder", | ||
"project_todo.mail_activity_data_reminder", | ||
), | ||
] | ||
|
||
|
||
def _convert_note_tag_to_project_tags(env): | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
INSERT INTO project_tags ( | ||
color, create_uid, write_uid, name, create_date, write_date | ||
) | ||
SELECT color, create_uid, write_uid, name, create_date, write_date | ||
FROM note_tag | ||
ON CONFLICT (name) DO NOTHING; | ||
""", | ||
) | ||
|
||
|
||
def _convert_note_note_to_project_task(env): | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
ALTER TABLE project_task ADD COLUMN openupgrade_legacy_note_id INTEGER; | ||
INSERT INTO project_task( | ||
create_uid, write_uid, create_date, write_date, | ||
active, name, description, priority, sequence, state, project_id, | ||
display_in_project, company_id, color, openupgrade_legacy_note_id | ||
) | ||
SELECT create_uid, write_uid, create_date, write_date, | ||
open, name, memo, '0', sequence, '01_in_progress', null, | ||
true, company_id, color, id | ||
FROM note_note | ||
""", | ||
) | ||
|
||
|
||
def _fill_project_tags(env): | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
INSERT INTO project_tags_project_task_rel (project_task_id, project_tags_id) | ||
SELECT | ||
project_task.id AS project_task_id, | ||
project_tags.id AS project_tags_id | ||
FROM note_tags_rel | ||
JOIN note_note ON note_tags_rel.note_id = note_note.id | ||
JOIN project_task ON project_task.openupgrade_legacy_note_id = note_note.id | ||
JOIN note_tag ON note_tags_rel.tag_id = note_tag.id | ||
JOIN project_tags ON project_tags.name = note_tag.name; | ||
""", | ||
) | ||
|
||
|
||
def _fill_stage_for_todo_task(env): | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
ALTER TABLE project_task_type ADD COLUMN note_stage_id INTEGER; | ||
INSERT INTO project_task_type ( | ||
create_uid, write_uid, create_date, write_date, active, | ||
user_id, sequence, name, fold, note_stage_id | ||
) | ||
SELECT | ||
create_uid, write_uid, create_date, write_date, true, | ||
user_id, sequence, name, fold, id | ||
FROM note_stage | ||
""", | ||
) | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
INSERT INTO project_task_user_rel( | ||
task_id, user_id, stage_id | ||
) | ||
SELECT | ||
project_task.id task_id, | ||
project_task_type.user_id, | ||
project_task_type.id stage_id | ||
FROM note_stage_rel rel | ||
JOIN project_task ON project_task.openupgrade_legacy_note_id = rel.note_id | ||
JOIN project_task_type ON project_task_type.note_stage_id = rel.stage_id | ||
""", | ||
) | ||
|
||
|
||
def _drop_tmp_columns(env): | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
ALTER TABLE project_task DROP COLUMN openupgrade_legacy_note_id; | ||
ALTER TABLE project_task_type DROP COLUMN note_stage_id; | ||
""", | ||
) | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
_convert_note_tag_to_project_tags(env) | ||
_convert_note_note_to_project_task(env) | ||
_fill_project_tags(env) | ||
_fill_stage_for_todo_task(env) | ||
openupgrade.merge_models( | ||
env.cr, "note.note", "project.task", "openupgrade_legacy_note_id" | ||
) | ||
_drop_tmp_columns(env) | ||
openupgrade.rename_xmlids(env.cr, _rename_xmlids) |
40 changes: 40 additions & 0 deletions
40
openupgrade_scripts/scripts/project_todo/17.0.1.0/upgrade_analysis_work.txt
This file contains 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,40 @@ | ||
---Models in module 'project_todo'--- | ||
new model mail.activity.todo.create [transient] | ||
# NOTHING TO DO | ||
|
||
---Fields in module 'project_todo'--- | ||
project_todo / mail.activity.type / category (False) : previously in module note | ||
NOTHING TO DO | ||
|
||
---XML records in module 'project_todo'--- | ||
NEW ir.actions.act_window: project_todo.project_task_action_convert_todo_to_task | ||
NEW ir.actions.act_window: project_todo.project_task_action_todo | ||
NEW ir.actions.act_window.view: project_todo.project_task_action_convert_todo_to_task_form_view | ||
NEW ir.actions.act_window.view: project_todo.project_task_action_todo_activity_view | ||
NEW ir.actions.act_window.view: project_todo.project_task_action_todo_form_view | ||
NEW ir.actions.act_window.view: project_todo.project_task_action_todo_kanban_view | ||
NEW ir.actions.act_window.view: project_todo.project_task_action_todo_tree_view | ||
NEW ir.actions.server: project_todo.project_task_preload_action_todo | ||
NEW ir.model.access: project_todo.access_mail_activity_todo_create | ||
NEW ir.model.access: project_todo.access_project_tags_user | ||
NEW ir.model.access: project_todo.access_project_task_type_user | ||
NEW ir.model.access: project_todo.access_task_on_partner | ||
NEW ir.rule: project_todo.task_edition_rule_internal (noupdate) | ||
NEW ir.rule: project_todo.task_visibility_rule_project_user (noupdate) | ||
NEW ir.ui.menu: project_todo.menu_todo_todos | ||
NEW ir.ui.view: project_todo.mail_activity_todo_create_popup | ||
NEW ir.ui.view: project_todo.project_task_view_todo_activity | ||
NEW ir.ui.view: project_todo.project_task_view_todo_conversion_form | ||
NEW ir.ui.view: project_todo.project_task_view_todo_form | ||
NEW ir.ui.view: project_todo.project_task_view_todo_kanban | ||
NEW ir.ui.view: project_todo.project_task_view_todo_quick_create_form | ||
NEW ir.ui.view: project_todo.project_task_view_todo_search | ||
NEW ir.ui.view: project_todo.project_task_view_todo_tree | ||
NEW ir.ui.view: project_todo.todo_user_onboarding (noupdate) | ||
# NOTHING TO DO: new feature | ||
|
||
NEW mail.activity.type: project_todo.mail_activity_data_reminder [renamed from note module] (noupdate) | ||
# DONE: rename in pre-migration | ||
|
||
NEW res.groups: project_todo.group_onboarding_todo | ||
# NOTHING TO DO: new feature |