Skip to content

Commit

Permalink
[OU-ADD] onboarding: migrate to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
duong77476-viindoo committed Jun 13, 2024
1 parent 9279df1 commit 7521610
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docsource/modules160-170.rst
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ Module coverage 16.0 -> 17.0
+---------------------------------------------------+----------------------+-------------------------------------------------+
| |del| note | |Renamed to project_todo. |
+---------------------------------------------------+----------------------+-------------------------------------------------+
| onboarding | | |
| onboarding | Done | |
+---------------------------------------------------+----------------------+-------------------------------------------------+
| partner_autocomplete | | |
+---------------------------------------------------+----------------------+-------------------------------------------------+
Expand Down
33 changes: 33 additions & 0 deletions openupgrade_scripts/scripts/onboarding/17.0.1.2/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2024 Viindoo Technology Joint Stock Company (Viindoo)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from openupgradelib import openupgrade


def _onboarding_step_convert_field_m2o_to_m2m(env):
# Convert m2o to m2m in 'onboarding.onboarding.step'
openupgrade.m2o_to_x2m(
env.cr,
env["onboarding.onboarding.step"],
"onboarding_onboarding_step",
"onboarding_ids",
"onboarding_id",
)


def _onboarding_progress_step_convert_field_m2o_to_m2m(env):
"""
Convert m2o to m2m in 'onboarding.progress.step'
"""
openupgrade.m2o_to_x2m(
env.cr,
env["onboarding.progress.step"],
"onboarding_progress_step",
"progress_ids",
"progress_id",
)


@openupgrade.migrate()
def migrate(env, version):
_onboarding_step_convert_field_m2o_to_m2m(env)
_onboarding_progress_step_convert_field_m2o_to_m2m(env)
27 changes: 27 additions & 0 deletions openupgrade_scripts/scripts/onboarding/17.0.1.2/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2024 Viindoo Technology Joint Stock Company (Viindoo)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from openupgradelib import openupgrade


def _onboarding_step_update_is_per_company(env):
openupgrade.logged_query(
env.cr,
"""
ALTER TABLE onboarding_onboarding_step
ADD COLUMN IF NOT EXISTS is_per_company BOOLEAN;
""",
)
openupgrade.logged_query(
env.cr,
"""
UPDATE onboarding_onboarding_step t1
SET is_per_company = true
FROM onboarding_onboarding t2
WHERE t1.onboarding_id = t2.id AND t2.is_per_company = true
""",
)


@openupgrade.migrate()
def migrate(env, version):
_onboarding_step_update_is_per_company(env)
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---Models in module 'onboarding'---
---Fields in module 'onboarding'---
onboarding / onboarding.onboarding / is_per_company (boolean) : not stored anymore
onboarding / onboarding.onboarding / is_per_company (boolean) : now a function
onboarding / onboarding.onboarding.step / is_per_company (boolean) : NEW hasdefault: default
# DONE pre-migration: update is_per_company for each steps

onboarding / onboarding.onboarding / panel_background_color (selection): DEL selection_keys: ['blue', 'none', 'orange', 'violet']
onboarding / onboarding.onboarding / panel_background_image (binary): DEL attachment: True
# NOTHING TO DO

onboarding / onboarding.onboarding / step_ids (one2many) : table is now 'onboarding_onboarding_onboarding_onboarding_step_rel' ('False')
onboarding / onboarding.onboarding / step_ids (one2many) : type is now 'many2many' ('one2many')
onboarding / onboarding.onboarding / text_completed (char) : NEW hasdefault: default
# NOTHING TO DO: handle by ORM

onboarding / onboarding.onboarding.step / onboarding_id (many2one) : DEL relation: onboarding.onboarding, required
onboarding / onboarding.onboarding.step / onboarding_ids (many2many) : NEW relation: onboarding.onboarding
# DONE post-migration: convert from m2o to m2m

onboarding / onboarding.onboarding.step / step_image (binary) : NEW attachment: True
onboarding / onboarding.onboarding.step / step_image_alt (char) : NEW hasdefault: default
onboarding / onboarding.onboarding.step / step_image_filename (char) : NEW
# NOTHING TO DO

onboarding / onboarding.progress / progress_step_ids (one2many) : table is now 'onboarding_progress_onboarding_progress_step_rel' ('False')
onboarding / onboarding.progress / progress_step_ids (one2many) : type is now 'many2many' ('one2many')
# NOTHING TO DO: handle by ORM

onboarding / onboarding.progress.step / company_id (many2one) : NEW relation: res.company
# NOTHING TO DO

onboarding / onboarding.progress.step / progress_id (many2one) : DEL relation: onboarding.progress, required
onboarding / onboarding.progress.step / progress_ids (many2many) : NEW relation: onboarding.progress
# DONE pre-migration: convert from m2o to m2m

---XML records in module 'onboarding'---
DEL ir.model.constraint: onboarding.constraint_onboarding_progress_onboarding_company_uniq
DEL ir.model.constraint: onboarding.constraint_onboarding_progress_step_progress_step_uniq
NEW ir.ui.view: onboarding.onboarding_step
# NOTHING TO DO

0 comments on commit 7521610

Please sign in to comment.