Skip to content

Commit

Permalink
[OU-IMP] project: merge project_status
Browse files Browse the repository at this point in the history
  • Loading branch information
remytms committed Apr 18, 2024
1 parent f3afe94 commit f69c70a
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
1 change: 1 addition & 0 deletions openupgrade_scripts/apriori.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
"survey_description": "survey",
# OCA/project
"project_mail_chatter": "project",
"project_status": "project",
"project_task_dependency": "project",
"project_timeline_task_dependency": "project_timeline",
# OCA/timesheet
Expand Down
25 changes: 25 additions & 0 deletions openupgrade_scripts/scripts/project/15.0.1.2/post-migration.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from openupgradelib import openupgrade
import logging

_logger = logging.getLogger(__name__)


def _convert_project_task_assigned_users(env):
Expand Down Expand Up @@ -70,13 +73,35 @@ def _fill_project_task_display_project_id(env):
)


def _activate_project_stages_conditionally(env):
"""Activate project stages if module project_status was installed"""
project_status = env["ir.module.module"].search(
[
("name", "=", "project_status"),
],
limit=1,
)
_logger.info("Sate of project_status: %s", project_status.state)
if project_status.state == "to upgrade":
_logger.info("project_status module was installed so enable project stages")
internal_group = env.ref("base.group_user")
stage_group = env.ref("project.group_project_stages")
internal_group.implied_ids += stage_group

_logger.info("marking project_status as to be removed")
#env["ir.module.module"].search(
# [("name", "=", "project_status")], limit=1
#).button_immediate_uninstall()


@openupgrade.migrate()
def migrate(env, version):
_convert_project_task_assigned_users(env)
_add_followers_to_project_for_allowed_internal_users(env)
_add_followers_to_project_for_allowed_portal_users(env)
_add_followers_to_task_for_allowed_users(env)
_fill_project_task_display_project_id(env)
_activate_project_stages_conditionally(env)
openupgrade.load_data(env.cr, "project", "15.0.1.2/noupdate_changes.xml")
openupgrade.delete_record_translations(
env.cr,
Expand Down
54 changes: 54 additions & 0 deletions openupgrade_scripts/scripts/project/15.0.1.2/pre-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,64 @@ def rename_project_milestone_target_date(env):
)


def migrate_project_status(env):
"""Migrate project_status module if installed to
project.project.stages.
"""
if openupgrade.table_exists(env.cr, "project_status"):
openupgrade.rename_tables(
env.cr,
[("project_status", "project_project_stage")],
)
openupgrade.rename_columns(
env.cr,
{
"project_project_stage": [
("company_id", None),
("description", None),
("status_sequence", "sequence"),
("is_closed", None),
],
},
)
openupgrade.rename_columns(
env.cr,
{
"project_project": [
("project_status", "stage_id"),
],
},
)
# Remove project_status views
xmlids_views = [
"project.project_status_seq",
"project.project_status_view_list",
"project.project_status_action",
"project.project_status_menu",
"project.view_project",
"project.edit_project",
"project.project_project_view_form_simplified",
"project.project_view_kanban",
"project.view_project_project_filter",
]
#xmlids_security = [
# "project.project_status_company_rule",
# "project.project_status_user",
# "project.project_status_manager",
#]
openupgrade.delete_records_safely_by_xml_id(
env, xmlids_views, delete_childs=False
)
#openupgrade.delete_records_safely_by_xml_id(
# env, xmlids_security, delete_childs=False
#)


@openupgrade.migrate()
def migrate(env, version):
openupgrade.rename_columns(env.cr, _column_renames)
adapt_project_task_dependency(env)
fill_project_project_allow_task_dependencies(env)
fill_project_project_last_update_status(env)
rename_project_milestone_target_date(env)
migrate_project_status(env)

0 comments on commit f69c70a

Please sign in to comment.