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

[MIG][17.0] project_todo: migrate to 17.0 #643

Merged
merged 1 commit into from
Jun 7, 2024
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: 2 additions & 2 deletions docsource/modules160-170.rst
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ Module coverage 16.0 -> 17.0
+---------------------------------------------------+----------------------+-------------------------------------------------+
| mrp_subonctracting_landed_costs |Nothing to do |No analysis file |
+---------------------------------------------------+----------------------+-------------------------------------------------+
| |del| note | |Renamed to project_todo. |
| |del| note |Done |Renamed to project_todo. |
+---------------------------------------------------+----------------------+-------------------------------------------------+
| onboarding | | |
+---------------------------------------------------+----------------------+-------------------------------------------------+
Expand Down Expand Up @@ -722,7 +722,7 @@ Module coverage 16.0 -> 17.0
+---------------------------------------------------+----------------------+-------------------------------------------------+
| project_timesheet_holidays | | |
+---------------------------------------------------+----------------------+-------------------------------------------------+
| |new| project_todo | |Renamed from note. |
| |new| project_todo |Done |Renamed from note. |
+---------------------------------------------------+----------------------+-------------------------------------------------+
| purchase | | |
+---------------------------------------------------+----------------------+-------------------------------------------------+
Expand Down
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 openupgrade_scripts/scripts/project_todo/17.0.1.0/pre-migration.py
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)
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
Loading