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

[17.0][OU-ADD] onboarding: migrate to 17.0 #4465

Merged
merged 1 commit into from
Oct 30, 2024
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/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",
pedrobaeza marked this conversation as resolved.
Show resolved Hide resolved
)


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",
pedrobaeza marked this conversation as resolved.
Show resolved Hide resolved
)


@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
Loading