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

[14.0][MIG] project #2826

Merged
merged 2 commits into from
Jul 15, 2021
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
2 changes: 1 addition & 1 deletion docsource/modules130-140.rst
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ Module coverage 13.0 -> 14.0
+--------------------------------------------+-------------------------------------------------+
|product_matrix | |
+--------------------------------------------+-------------------------------------------------+
|project | |
|project | Done |
+--------------------------------------------+-------------------------------------------------+
|project_timesheet_holidays | |
+--------------------------------------------+-------------------------------------------------+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<field name="parent_id" ref="mt_task_stage"/>
</record>
<record id="project_comp_rule" model="ir.rule">
<field name="global"/>
<!-- <field name="global"/>-->
</record>
<record id="project_project_rule_portal" model="ir.rule">
<field name="domain_force">[
Expand Down Expand Up @@ -83,10 +83,10 @@
</field>
</record>
<record id="report_project_task_user_report_comp_rule" model="ir.rule">
<field name="global"/>
<!-- <field name="global"/>-->
</record>
<record id="task_comp_rule" model="ir.rule">
<field name="global"/>
<!-- <field name="global"/>-->
</record>
<record id="task_visibility_rule" model="ir.rule">
<field name="domain_force">[
Expand Down
95 changes: 95 additions & 0 deletions openupgrade_scripts/scripts/project/14.0.1.1/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Copyright 2021 ForgeFlow S.L. <https://www.forgeflow.com>
# Copyright 2021 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openupgradelib import openupgrade


def map_project_project_rating_status(env):
openupgrade.map_values(
env.cr,
openupgrade.get_legacy_name("rating_status"),
"rating_status",
[("no", "stage")],
table="project_project",
)


def _fill_res_users_m2m_tables(env):
# TODO: Take into account channels and task followers part of the old rule
openupgrade.logged_query(
env.cr,
"""
INSERT INTO project_allowed_internal_users_rel
(project_project_id, res_users_id)
SELECT pp.id, ru.id
FROM project_project pp
JOIN mail_followers mf ON mf.res_model = 'project.project' AND mf.res_id = pp.id
JOIN res_users ru ON ru.partner_id = mf.partner_id AND NOT ru.share
WHERE pp.privacy_visibility = 'followers'
""",
)
openupgrade.logged_query(
env.cr,
"""
INSERT INTO project_allowed_portal_users_rel
(project_project_id, res_users_id)
SELECT pp.id, ru.id
FROM project_project pp
JOIN mail_followers mf ON mf.res_model = 'project.project' AND mf.res_id = pp.id
JOIN res_partner rp ON mf.partner_id = rp.id
OR mf.partner_id = rp.commercial_partner_id
JOIN res_users ru ON ru.partner_id = rp.id AND ru.share
WHERE pp.privacy_visibility = 'portal'
""",
)
openupgrade.logged_query(
env.cr,
"""
INSERT INTO project_task_res_users_rel
(project_task_id, res_users_id)
SELECT pt.id, rel.res_users_id
FROM project_allowed_internal_users_rel rel
JOIN project_task pt ON pt.project_id = rel.project_project_id
UNION
SELECT pt.id, rel.res_users_id
FROM project_allowed_portal_users_rel rel
JOIN project_task pt ON pt.project_id = rel.project_project_id
""",
)


@openupgrade.migrate()
def migrate(env, version):
map_project_project_rating_status(env)
_fill_res_users_m2m_tables(env)
openupgrade.load_data(env.cr, "project", "14.0.1.1/noupdate_changes.xml")
openupgrade.delete_records_safely_by_xml_id(
env,
[
"project.msg_task_4",
"project.project_task_data_0",
"project.project_task_data_1",
"project.project_task_data_11",
"project.project_task_data_12",
"project.project_task_data_13",
"project.project_task_data_14",
"project.project_task_data_2",
"project.project_task_data_4",
"project.project_task_data_5",
"project.project_task_data_6",
"project.project_task_data_7",
"project.project_task_data_9",
"project.project_stage_data_0",
"project.project_stage_data_1",
"project.project_stage_data_2",
# We do this at the end for assuring not having this records assigned on the
# rest of the demo data
"project.project_project_data",
"project.project_tag_data",
],
)
openupgrade.delete_record_translations(
env.cr,
"project",
["mail_template_data_project_task", "rating_project_request_email_template"],
)
54 changes: 54 additions & 0 deletions openupgrade_scripts/scripts/project/14.0.1.1/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Copyright 2021 ForgeFlow S.L. <https://www.forgeflow.com>
# Copyright 2021 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openupgradelib import openupgrade


def _set_default_rating_status_period(env):
openupgrade.logged_query(
env.cr,
"UPDATE project_project SET rating_status_period = 'monthly' WHERE "
"rating_status_period IS NULL",
)


@openupgrade.migrate()
def migrate(env, version):
openupgrade.copy_columns(
env.cr,
{
"project_project": [
("rating_status", None, None),
],
},
)
openupgrade.rename_fields(
env,
[
(
"project.project",
"project_project",
"portal_show_rating",
"rating_active",
),
],
)
openupgrade.rename_xmlids(
env.cr,
[
("project.access_partner_task user", "project.access_partner_task_user"),
],
)
_set_default_rating_status_period(env)
# Manually create tables for avoiding the automatic launch of the compute or default
# FK constraints and indexes will be added by ORM
openupgrade.logged_query(
env.cr,
"""CREATE TABLE project_allowed_internal_users_rel
(project_project_id INTEGER, res_users_id INTEGER)""",
)
openupgrade.logged_query(
env.cr,
"""CREATE TABLE project_task_res_users_rel
pedrobaeza marked this conversation as resolved.
Show resolved Hide resolved
(project_task_id INTEGER, res_users_id INTEGER)""",
)
150 changes: 150 additions & 0 deletions openupgrade_scripts/scripts/project/14.0.1.1/upgrade_analysis_work.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
---Models in module 'project'---
new model project.delete.wizard [transient]
new model project.task.recurrence
new model project.task.type.delete.wizard [transient]
# NOTHING TO DO

---Fields in module 'project'---
project / project.project / allow_recurring_tasks (boolean): NEW hasdefault
project / project.project / allow_subtasks (boolean) : NEW hasdefault
# NOTHING TO DO: new features

project / project.project / description (html) : NEW
# NOTHING TO DO: New feature

project / project.project / partner_email (char) : NEW isfunction: function, stored
project / project.project / partner_phone (char) : NEW isfunction: function, stored
# NOTHING TO DO: Stored by ORM

project / project.project / portal_show_rating (boolean) : DEL
project / project.project / rating_active (boolean) : NEW hasdefault
# DONE: pre-migration: renamed field

project / project.project / rating_status (selection) : selection_keys is now '['periodic', 'stage']' ('['no', 'periodic', 'stage']')
# DONE: pre-migration: copy column for preserving data
# DONE: post-migration: map 'no' to 'stage'

project / project.project / rating_status_period (selection): now required, req_default: function
# DONE: pre-migration: Apply default if no value

project / project.project / resource_calendar_id (many2one): not stored anymore
project / project.project / resource_calendar_id (many2one): now related
# NOTHING TO DO: There's the possibility of having another calendar in v13, but as this was only used for computing number of working days and hours till closed, it's OK to ignore it

project / project.project / allowed_internal_user_ids (many2many): NEW relation: res.users, hasdefault
project / project.project / allowed_portal_user_ids (many2many): NEW relation: res.users
project / project.task / allowed_user_ids (many2many) : NEW relation: res.users, isfunction: function, stored
# DONE: pre-migration: Pre-create tables for not launching the default + computed
# DONE: post-migration: fill these tables from followers

project / project.task / company_id (many2one) : now a function
project / project.task / email_from (char) : now a function
project / project.task / partner_email (char) : NEW isfunction: function, stored
project / project.task / partner_id (many2one) : now a function
project / project.task / partner_phone (char) : NEW isfunction: function, stored
project / project.task / project_id (many2one) : now a function
project / project.task / stage_id (many2one) : now a function
# NOTHING TO DO: compute methods that will launch when loading

project / project.task / recurrence_id (many2one) : NEW relation: project.task.recurrence
project / project.task / recurrence_update (selection) : NEW selection_keys: ['all', 'subsequent', 'this'], hasdefault
project / project.task / recurring_task (boolean) : NEW
# NOTHING TO DO: recurrences are a new feature

project / project.task.recurrence / fri (boolean) : NEW
project / project.task.recurrence / mon (boolean) : NEW
project / project.task.recurrence / next_recurrence_date (date) : NEW
project / project.task.recurrence / recurrence_left (integer) : NEW
project / project.task.recurrence / repeat_day (selection) : NEW selection_keys: ['1', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '2', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '3', '30', '31', '4', '5', '6', '7', '8', '9']
project / project.task.recurrence / repeat_interval (integer) : NEW hasdefault
project / project.task.recurrence / repeat_month (selection) : NEW selection_keys: ['april', 'august', 'december', 'february', 'january', 'july', 'june', 'march', 'may', 'november', 'october', 'september']
project / project.task.recurrence / repeat_number (integer) : NEW
project / project.task.recurrence / repeat_on_month (selection) : NEW selection_keys: ['date', 'day']
project / project.task.recurrence / repeat_on_year (selection) : NEW selection_keys: ['date', 'day']
project / project.task.recurrence / repeat_type (selection) : NEW selection_keys: ['after', 'forever', 'until'], hasdefault
project / project.task.recurrence / repeat_unit (selection) : NEW selection_keys: ['day', 'month', 'week', 'year'], hasdefault
project / project.task.recurrence / repeat_until (date) : NEW
project / project.task.recurrence / repeat_week (selection) : NEW selection_keys: ['first', 'last', 'second', 'third']
project / project.task.recurrence / repeat_weekday (selection) : NEW selection_keys: ['fri', 'mon', 'sat', 'sun', 'thu', 'tue', 'wed']
project / project.task.recurrence / sat (boolean) : NEW
project / project.task.recurrence / sun (boolean) : NEW
project / project.task.recurrence / task_ids (one2many) : NEW relation: project.task
project / project.task.recurrence / thu (boolean) : NEW
project / project.task.recurrence / tue (boolean) : NEW
project / project.task.recurrence / wed (boolean) : NEW
# NOTHING TO DO: new model, empty when migrating

project / project.task.type / active (boolean) : NEW hasdefault
# NOTHING TO DO: has default true

project / project.task.type / is_closed (boolean) : NEW
# NOTHING TO DO: new feature (comes from enterprise)

---XML records in module 'project'---
NEW ir.actions.act_window: project.action_view_all_task
NEW ir.actions.act_window: project.open_task_type_form_domain
NEW ir.actions.act_window.view: project.rating_rating_action_project_report_form
NEW ir.actions.act_window.view: project.rating_rating_action_project_report_graph
NEW ir.actions.act_window.view: project.rating_rating_action_project_report_pivot
NEW ir.actions.act_window.view: project.rating_rating_action_project_report_tree
NEW ir.actions.act_window.view: project.rating_rating_action_task_form
NEW ir.actions.act_window.view: project.rating_rating_action_task_graph
NEW ir.actions.act_window.view: project.rating_rating_action_task_pivot
NEW ir.actions.act_window.view: project.rating_rating_action_task_tree
NEW ir.actions.act_window.view: project.rating_rating_action_view_project_rating_form
NEW ir.actions.act_window.view: project.rating_rating_action_view_project_rating_graph
NEW ir.actions.act_window.view: project.rating_rating_action_view_project_rating_pivot
NEW ir.actions.act_window.view: project.rating_rating_action_view_project_rating_tree
NEW ir.actions.server: project.unlink_project_action
NEW ir.actions.server: project.unlink_task_type_action
DEL ir.actions.server: project.ir_actions_server_project_sample
NEW ir.cron: project.ir_cron_recurring_tasks (noupdate)
DEL ir.filters: project.filter_task_report_cumulative_flow
DEL ir.filters: project.filter_task_report_responsible
DEL ir.filters: project.filter_task_report_task_pipe
DEL ir.filters: project.filter_task_report_workload
# NOTHING TO DO

DEL ir.model.access: project.access_partner_task user
NEW ir.model.access: project.access_partner_task_user
# DONE: pre-migration: renamed xmlid

NEW ir.model.access: project.access_project_delete_wizard
NEW ir.model.access: project.access_project_task_recurrence
NEW ir.model.access: project.access_project_task_type_delete_wizard
DEL ir.model.access: project.access_mail_alias
NEW ir.ui.view: project.project_delete_wizard_form
NEW ir.ui.view: project.rating_rating_view_form_project
NEW ir.ui.view: project.rating_rating_view_graph
NEW ir.ui.view: project.rating_rating_view_pivot
NEW ir.ui.view: project.rating_rating_view_tree_project
NEW ir.ui.view: project.view_project_task_type_delete_confirmation_wizard
NEW ir.ui.view: project.view_project_task_type_delete_wizard
DEL ir.ui.view: project.portal_project_rating_partner_stat
DEL ir.ui.view: project.portal_project_rating_popover
DEL ir.ui.view: project.portal_project_rating_progressbar
DEL ir.ui.view: project.project_view_kanban
DEL ir.ui.view: project.rating_index
DEL ir.ui.view: project.rating_project_rating_page
NEW res.groups: project.group_project_recurring_tasks
# NOTHING TO DO

DEL mail.message: project.msg_task_4 (noupdate)
DEL project.project: project.project_project_data (noupdate)
DEL project.tags: project.project_tag_data (noupdate)
DEL project.task: project.project_task_data_0 (noupdate)
DEL project.task: project.project_task_data_1 (noupdate)
DEL project.task: project.project_task_data_11 (noupdate)
DEL project.task: project.project_task_data_12 (noupdate)
DEL project.task: project.project_task_data_13 (noupdate)
DEL project.task: project.project_task_data_14 (noupdate)
DEL project.task: project.project_task_data_2 (noupdate)
DEL project.task: project.project_task_data_4 (noupdate)
DEL project.task: project.project_task_data_5 (noupdate)
DEL project.task: project.project_task_data_6 (noupdate)
DEL project.task: project.project_task_data_7 (noupdate)
DEL project.task: project.project_task_data_9 (noupdate)
DEL project.task.type: project.project_stage_data_0 (noupdate)
DEL project.task.type: project.project_stage_data_1 (noupdate)
DEL project.task.type: project.project_stage_data_2 (noupdate)
# DONE: post-migration: assure safely deletion