Skip to content

Commit

Permalink
Merge pull request #2280 from Yasaie/13.0-mig-project
Browse files Browse the repository at this point in the history
[13.0][MIG] project
  • Loading branch information
pedrobaeza authored Nov 11, 2020
2 parents 2471a96 + af0960f commit e8abd40
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 1 deletion.
50 changes: 50 additions & 0 deletions addons/project/migrations/13.0.1.1/openupgrade_analysis_work.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---Models in module 'project'---
---Fields in module 'project'---
project / account.analytic.account / project_count (integer) : previously in module hr_timesheet
project / account.analytic.account / project_ids (one2many) : previously in module hr_timesheet
project / project.project / analytic_account_id (many2one): previously in module hr_timesheet
# DONE: pre-migration: Update field definition

project / project.project / percentage_satisfaction_project (integer): DEL
project / project.project / percentage_satisfaction_task (integer): DEL
# NOTHING TO DO: Features removed

project / project.project / rating_ids (one2many) : NEW relation: rating.rating
# NOTHING TO DO: New one2many field

project / project.task / company_id (many2one) : now required, req_default: function
# DONE: pre-migration: filled the field when empty

project / project.task / date_start (datetime) : DEL
project / project.task / notes (text) : DEL
project / project.task.type / legend_priority (char) : DEL
# NOTHING TO DO: Features removed

---XML records in module 'project'---
NEW ir.model.access: project.access_account_analytic_account_manager [renamed from hr_timesheet module]
NEW ir.model.access: project.access_account_analytic_account_user [renamed from hr_timesheet module]
NEW ir.model.access: project.access_account_analytic_line_project [renamed from hr_timesheet module]
# DONE: pre-migration (renamed)

NEW ir.module.category: base.module_category_operations_project (noupdate)
# NOTHING TO DO: New record

NEW ir.actions.act_window: project.portal_share_action
NEW ir.ui.view: project.account_analytic_account_view_form_inherit
NEW ir.ui.view: project.project_project_view_form_simplified_footer
NEW ir.ui.view: project.project_tags_tree_view
NEW ir.ui.view: project.project_task_view_activity
DEL ir.ui.view: project.qunit_suite
# NOTHING TO DO: noupdate=0 ir records

mail.message.subtype: project.mt_project_task_blocked (noupdate) (noupdate switched)
mail.message.subtype: project.mt_project_task_new (noupdate) (noupdate switched)
mail.message.subtype: project.mt_project_task_rating (noupdate) (noupdate switched)
mail.message.subtype: project.mt_project_task_ready (noupdate) (noupdate switched)
mail.message.subtype: project.mt_project_task_stage (noupdate) (noupdate switched)
mail.message.subtype: project.mt_task_blocked (noupdate) (noupdate switched)
mail.message.subtype: project.mt_task_new (noupdate) (noupdate switched)
mail.message.subtype: project.mt_task_rating (noupdate) (noupdate switched)
mail.message.subtype: project.mt_task_ready (noupdate) (noupdate switched)
mail.message.subtype: project.mt_task_stage (noupdate) (noupdate switched)
# DONE: pre-migration
8 changes: 8 additions & 0 deletions addons/project/migrations/13.0.1.1/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright 2020 Payam Yasaie <https://www.tashilgostar.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openupgradelib import openupgrade


@openupgrade.migrate()
def migrate(env, version):
openupgrade.load_data(env.cr, 'project', 'migrations/13.0.1.1/noupdate_changes.xml')
64 changes: 64 additions & 0 deletions addons/project/migrations/13.0.1.1/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Copyright 2020 Payam Yasaie <https://www.tashilgostar.com>
# Copyright 2020 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openupgradelib import openupgrade

_xmlid_renames = [
('hr_timesheet.access_account_analytic_account_manager', 'project.access_account_analytic_account_manager'),
('hr_timesheet.access_account_analytic_account_user', 'project.access_account_analytic_account_user'),
('hr_timesheet.access_account_analytic_line_project', 'project.access_account_analytic_line_project'),
]


def update_module_moved_fields(env):
if not openupgrade.is_module_installed(env.cr, "hr_timesheet"):
return
openupgrade.update_module_moved_fields(
env.cr,
"account.analytic.account",
["project_count", "project_ids"],
"hr_timesheet",
"project",
)
openupgrade.update_module_moved_fields(
env.cr,
"project.project",
["analytic_account_id"],
"hr_timesheet",
"project",
)


def fill_project_task_company_id(cr):
openupgrade.logged_query(
cr, """
UPDATE project_task pt
SET company_id = pp.company_id
FROM project_project pp
WHERE pp.id = pt.project_id AND pt.company_id IS NULL
"""
)


@openupgrade.migrate()
def migrate(env, version):
openupgrade.rename_xmlids(env.cr, _xmlid_renames)
update_module_moved_fields(env)
fill_project_task_company_id(env.cr)
openupgrade.set_xml_ids_noupdate_value(
env,
"project",
[
"mt_project_task_blocked",
"mt_project_task_new",
"mt_project_task_rating",
"mt_project_task_ready",
"mt_project_task_stage",
"mt_task_blocked",
"mt_task_new",
"mt_task_rating",
"mt_task_ready",
"mt_task_stage",
],
True,
)
2 changes: 1 addition & 1 deletion odoo/openupgrade/doc/source/modules120-130.rst
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ missing in the new release are marked with |del|.
+----------------------------------------------+-------------------------------------------------+
| |new| product_matrix | |
+----------------------------------------------+-------------------------------------------------+
|project | |
|project | Done |
+----------------------------------------------+-------------------------------------------------+
|project_timesheet_holidays | |
+----------------------------------------------+-------------------------------------------------+
Expand Down

0 comments on commit e8abd40

Please sign in to comment.