-
-
Notifications
You must be signed in to change notification settings - Fork 696
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
Showing
4 changed files
with
286 additions
and
1 deletion.
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
6 changes: 6 additions & 0 deletions
6
openupgrade_scripts/scripts/project/16.0.1.2/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,6 @@ | ||
from openupgradelib import openupgrade | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
openupgrade.load_data(env.cr, "project", "16.0.1.2/noupdate_changes.xml") |
173 changes: 173 additions & 0 deletions
173
openupgrade_scripts/scripts/project/16.0.1.2/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,173 @@ | ||
from openupgradelib import openupgrade | ||
|
||
|
||
def _create_column_for_avoiding_automatic_computing(env): | ||
""" | ||
Create some new columns in the database and set values for them | ||
to avoid computing by ORM | ||
""" | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
ALTER TABLE project_task | ||
ADD COLUMN IF NOT EXISTS is_analytic_account_id_changed boolean; | ||
""", | ||
) | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
ALTER TABLE project_task | ||
ADD COLUMN IF NOT EXISTS is_closed boolean; | ||
""", | ||
) | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
ALTER TABLE project_task | ||
ADD COLUMN IF NOT EXISTS is_blocked boolean; | ||
""", | ||
) | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
ALTER TABLE project_task | ||
ADD COLUMN IF NOT EXISTS ancestor_id integer; | ||
""", | ||
) | ||
|
||
|
||
def _fill_project_last_update_status_if_null(env): | ||
""" | ||
In some cases, the user can go to the DB and reset the `last_update_status` | ||
field to NULL. In version 16.0 it is necessary to reset it to `to_define` | ||
because it has a `required` attribute. | ||
""" | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
UPDATE project_project project | ||
SET last_update_status = 'to_define' | ||
WHERE last_update_status IS NULL; | ||
""", | ||
) | ||
|
||
|
||
def _set_task_stage_type_to_fold_if_is_closed(env): | ||
""" | ||
In version 16.0, task stages with type `is_closed` will be removed. | ||
just use the `fold` style instead. Therefore, it is necessary to define | ||
the phase types as `is_closed` and return them to `fold` | ||
""" | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
UPDATE project_task_type | ||
SET fold = TRUE | ||
WHERE is_closed = TRUE; | ||
""", | ||
) | ||
|
||
|
||
def _fill_project_task_is_analytic_account_id_changed(env): | ||
""" | ||
`is_analytic_account_id_changed` is a new field at version 16.0. | ||
It has a value of False if you have the same admin account as the project, | ||
otherwise it will have a value of True | ||
""" | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
UPDATE project_task task | ||
SET is_analytic_account_id_changed = CASE | ||
WHEN task.analytic_account_id = project.analytic_account_id THEN FALSE | ||
ELSE TRUE | ||
END | ||
FROM project_project as project | ||
WHERE task.project_id = project.id; | ||
""", | ||
) | ||
|
||
|
||
def _fill_project_task_is_closed(env): | ||
# `is_closed` field will be store at version 16.0 | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
UPDATE project_task task | ||
SET is_closed = CASE | ||
WHEN stage.fold = TRUE THEN TRUE | ||
ELSE FALSE | ||
END | ||
FROM project_task_type stage | ||
WHERE task.stage_id = stage.id; | ||
""", | ||
) | ||
|
||
|
||
def _fill_project_task_is_blocked(env): | ||
""" | ||
A new column in version 16.0, which evaluates to True if at least 1 task it | ||
depends on is blocked or is closed. In contrast, all the tasks on which it | ||
depends are closed and not blocked. This task is ready and has the value | ||
`is_blocked=False` | ||
""" | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
UPDATE project_task | ||
SET is_blocked = TRUE | ||
WHERE id IN ( | ||
SELECT task_id | ||
FROM task_dependencies_rel | ||
WHERE depends_on_id IN (SELECT id FROM project_task WHERE is_closed = FALSE) | ||
); | ||
UPDATE project_task | ||
SET is_blocked = FALSE | ||
WHERE id NOT IN ( | ||
SELECT task_id | ||
FROM task_dependencies_rel | ||
WHERE depends_on_id IN (SELECT id FROM project_task WHERE is_closed = FALSE) | ||
); | ||
""", | ||
) | ||
|
||
|
||
def _fil_project_task_ancestor_id(env): | ||
""" | ||
New column at version 16.0. valid as the ancestor of the current task | ||
""" | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
WITH RECURSIVE task_ancestors AS ( | ||
SELECT id, parent_id, id AS ancestor_id | ||
FROM project_task | ||
WHERE parent_id IS NULL | ||
UNION ALL | ||
SELECT pt.id, pt.parent_id, ta.ancestor_id | ||
FROM project_task pt | ||
INNER JOIN task_ancestors ta ON pt.parent_id = ta.id | ||
) | ||
UPDATE project_task pt | ||
SET ancestor_id = ta.ancestor_id | ||
FROM task_ancestors ta | ||
WHERE pt.id = ta.id; | ||
UPDATE project_task pt | ||
SET ancestor_id = NULL | ||
WHERE id = ancestor_id; | ||
""", | ||
) | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
_create_column_for_avoiding_automatic_computing(env) | ||
_fill_project_last_update_status_if_null(env) | ||
_set_task_stage_type_to_fold_if_is_closed(env) | ||
_fill_project_task_is_analytic_account_id_changed(env) | ||
_fill_project_task_is_closed(env) | ||
_fill_project_task_is_blocked(env) | ||
_fil_project_task_ancestor_id(env) |
106 changes: 106 additions & 0 deletions
106
openupgrade_scripts/scripts/project/16.0.1.2/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,106 @@ | ||
---Models in module 'project'--- | ||
obsolete model project.delete.wizard [transient] | ||
---Fields in module 'project'--- | ||
project / account.analytic.tag / task_ids (many2many) : DEL relation: project.task | ||
project / project.milestone / task_ids (one2many) : NEW relation: project.task | ||
project / project.project / allow_milestones (boolean) : NEW hasdefault: default | ||
# NOTHING TO DO | ||
|
||
project / project.project / last_update_status (selection): not a function anymore | ||
project / project.project / last_update_status (selection): now required | ||
project / project.project / last_update_status (selection): selection_keys is now '['at_risk', 'off_track', 'on_hold', 'on_track', 'to_define']' ('['at_risk', 'off_track', 'on_hold', 'on_track']') | ||
# DONE: pre-migration: set value to `to_define` if last_update_status IS NULL | ||
|
||
project / project.project / task_properties_definition (properties_definition): NEW | ||
project / project.tags / project_ids (many2many) : NEW relation: project.project | ||
project / project.tags / task_ids (many2many) : NEW relation: project.task | ||
# NOTHING TO DO | ||
|
||
project / project.task / analytic_tag_ids (many2many) : DEL relation: account.analytic.tag | ||
# NOTHING TO DO | ||
|
||
project / project.task / ancestor_id (many2one) : NEW relation: project.task, isfunction: function, stored | ||
# DONE: pre-migration: Add new column & set value for it | ||
|
||
project / project.task / is_analytic_account_id_changed (boolean): NEW isfunction: function, stored | ||
# DONE: pre-migration: Add new column & set value for it | ||
|
||
project / project.task / is_blocked (boolean) : NEW isfunction: function, stored | ||
# DONE: pre-migration: Add new column & set value for it | ||
|
||
project / project.task / is_closed (boolean) : is now stored | ||
# DONE: pre-migration: Add new column & set value for it | ||
|
||
project / project.task / milestone_id (many2one) : NEW relation: project.milestone, hasdefault: compute | ||
# NOTHING TO DO | ||
|
||
project / project.task / task_properties (properties) : NEW hasdefault: compute | ||
# NOTHING TO DO | ||
|
||
project / project.task.type / is_closed (boolean) : DEL | ||
# DONE: pre-migration: Move value to fold stage | ||
|
||
project / res.company / analytic_plan_id (many2one) : NEW relation: account.analytic.plan, hasdefault: compute | ||
# NOTHING TO DO | ||
|
||
---XML records in module 'project'--- | ||
NEW digest.tip: project.digest_tip_project_1 | ||
NEW ir.actions.act_window: project.action_send_mail_project_project | ||
NEW ir.actions.act_window: project.action_send_mail_project_task | ||
NEW ir.actions.act_window: project.action_view_task_from_milestone | ||
NEW ir.actions.act_window: project.open_view_project_all_config_group_stage | ||
NEW ir.actions.act_window: project.project_sharing_project_task_action_sub_task | ||
NEW ir.actions.act_window: project.project_task_action_sub_task | ||
# NOTHING TO DO | ||
|
||
DEL ir.actions.act_window: project.project_milestone_all | ||
NEW ir.actions.act_window.view: project.open_view_all_task_list_calendar | ||
NEW ir.actions.act_window.view: project.open_view_all_task_list_kanban | ||
NEW ir.actions.act_window.view: project.open_view_all_task_list_tree | ||
NEW ir.actions.act_window.view: project.open_view_project_all_config_group_stage_kanban_action_view | ||
NEW ir.actions.act_window.view: project.open_view_project_all_config_group_stage_tree_action_view | ||
NEW ir.actions.act_window.view: project.project_all_task_activity_action_view | ||
NEW ir.actions.act_window.view: project.project_all_task_calendar_action_view | ||
NEW ir.actions.act_window.view: project.project_all_task_graph_action_view | ||
NEW ir.actions.act_window.view: project.project_all_task_pivot_action_view | ||
NEW ir.actions.act_window.view: project.project_sharing_subtasks_form_action_view | ||
NEW ir.actions.act_window.view: project.project_sharing_subtasks_kanban_action_view | ||
NEW ir.actions.act_window.view: project.project_sharing_subtasks_tree_action_view | ||
NEW ir.actions.act_window.view: project.project_task_form_action_view | ||
NEW ir.actions.act_window.view: project.project_task_kanban_action_view | ||
NEW ir.actions.act_window.view: project.project_task_tree_action_view | ||
NEW ir.actions.act_window.view: project.rating_rating_action_task_kanban | ||
NEW ir.actions.act_window.view: project.rating_rating_action_view_project_rating_kanban | ||
# NOTHING TO DO | ||
|
||
DEL ir.actions.server: project.unlink_project_action | ||
NEW ir.model.access: project.access_project_task_burndown_chart_report_user | ||
NEW ir.model.access: project.access_report_project_task_user_project_user | ||
DEL ir.model.access: project.access_project_delete_wizard | ||
# NOTHING TO DO | ||
|
||
NEW ir.rule: project.burndown_chart_project_manager_rule (noupdate) | ||
NEW ir.rule: project.burndown_chart_project_user_rule (noupdate) | ||
NEW ir.rule: project.report_project_task_manager_rule (noupdate) | ||
NEW ir.rule: project.report_project_task_user_rule (noupdate) | ||
# NOTHING TO DO | ||
|
||
NEW ir.ui.menu: project.menu_projects_config_group_stage | ||
NEW ir.ui.view: project.rating_rating_project_view_kanban | ||
NEW ir.ui.view: project.task_type_tree_inherited | ||
NEW ir.ui.view: project.view_project_calendar | ||
NEW ir.ui.view: project.view_project_config_kanban | ||
NEW ir.ui.view: project.view_project_task_pivot_inherit | ||
NEW ir.ui.view: project.view_project_task_type_unarchive_wizard | ||
NEW ir.ui.view: project.view_task_all_calendar | ||
NEW ir.ui.view: project.view_task_kanban_inherit_my_task | ||
DEL ir.ui.view: project.project_collaborator_view_form | ||
DEL ir.ui.view: project.project_delete_wizard_form | ||
DEL ir.ui.view: project.project_task_burndown_chart_report_view_pivot | ||
# NOTHING TO DO | ||
|
||
NEW mail.message.subtype: project.mt_project_update_create (noupdate) | ||
NEW mail.message.subtype: project.mt_task_progress (noupdate) | ||
NEW mail.message.subtype: project.mt_update_create (noupdate) | ||
NEW res.groups: project.group_project_milestone | ||
# NOTHING TO DO |