-
-
Notifications
You must be signed in to change notification settings - Fork 708
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4038 from Tecnativa/15.0-ou_add-website_event_que…
…stions [15.0][OU-ADD] website_event_questions: Migration scripts
- Loading branch information
Showing
5 changed files
with
81 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
openupgrade_scripts/scripts/website_event_questions/15.0.1.2/noupdate_changes.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
<?xml version='1.0' encoding='utf-8'?> | ||
<odoo> | ||
<record id="ir_rule_event_question_answer_event_user" model="ir.rule"> | ||
<field name="groups" eval="[(4, ref('event.group_event_registration_desk'))]"/> | ||
<field name="groups" eval="[(3, ref('event.group_event_user')), (4, ref('event.group_event_registration_desk'))]"/> | ||
</record> | ||
<record id="ir_rule_event_question_event_user" model="ir.rule"> | ||
<field name="groups" eval="[(4, ref('event.group_event_registration_desk'))]"/> | ||
<field name="groups" eval="[(3, ref('event.group_event_user')), (4, ref('event.group_event_registration_desk'))]"/> | ||
</record> | ||
</odoo> |
29 changes: 29 additions & 0 deletions
29
openupgrade_scripts/scripts/website_event_questions/15.0.1.2/post-migration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Copyright 2023 Tecnativa - Pedro M. Baeza | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from openupgradelib import openupgrade | ||
|
||
|
||
def _unlink_non_applicable_questions(env): | ||
"""Set event_type_id = NULL on existing questions if the field `event_question` was | ||
not marked in the event type. This way, we preserve possible existing answers, but | ||
non desired questions are not done for the events of that type. | ||
""" | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
UPDATE event_question eq | ||
SET event_type_id = NULL | ||
FROM event_type et | ||
WHERE et.id = eq.event_type_id | ||
AND NOT et.use_questions | ||
""", | ||
) | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
openupgrade.load_data( | ||
env.cr, "website_event_questions", "15.0.1.2/noupdate_changes.xml" | ||
) | ||
_unlink_non_applicable_questions(env) |
28 changes: 28 additions & 0 deletions
28
openupgrade_scripts/scripts/website_event_questions/15.0.1.2/pre-migration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Copyright 2023 Tecnativa - Pedro M. Baeza | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from openupgradelib import openupgrade | ||
|
||
_xmlid_renames = [ | ||
( | ||
"website_event_questions.event_question_all", | ||
"website_event_questions.access_event_question", | ||
), | ||
( | ||
"website_event_questions.event_question_event_user", | ||
"website_event_questions.access_event_question_user", | ||
), | ||
( | ||
"website_event_questions.event_question_answer_all", | ||
"website_event_questions.access_event_question_answer", | ||
), | ||
( | ||
"website_event_questions.event_question_answer_event_user", | ||
"website_event_questions.access_event_question_answer_user", | ||
), | ||
] | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
openupgrade.rename_xmlids(env.cr, _xmlid_renames) |
21 changes: 21 additions & 0 deletions
21
openupgrade_scripts/scripts/website_event_questions/15.0.1.2/upgrade_analysis_work.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
---Models in module 'website_event_questions'--- | ||
---Fields in module 'website_event_questions'--- | ||
website_event_questions / event.type / use_questions (boolean) : DEL | ||
# DONE: post-migration: Set event_type_id = NULL on existing questions if the field was not marked in the event type. This way, we preserve possible existing answers. | ||
|
||
---XML records in module 'website_event_questions'--- | ||
NEW ir.model.access: website_event_questions.access_event_question | ||
NEW ir.model.access: website_event_questions.access_event_question_answer | ||
NEW ir.model.access: website_event_questions.access_event_question_answer_user | ||
NEW ir.model.access: website_event_questions.access_event_question_user | ||
DEL ir.model.access: website_event_questions.event_question_all | ||
DEL ir.model.access: website_event_questions.event_question_answer_all | ||
DEL ir.model.access: website_event_questions.event_question_answer_event_user | ||
DEL ir.model.access: website_event_questions.event_question_event_user | ||
# DONE: pre-migration: Renamed XML-IDs | ||
|
||
DEL ir.model.access: website_event_questions.event_registration_answer_event_user | ||
DEL ir.ui.view: website_event_questions.assets_tests | ||
NEW ir.model.access: website_event_questions.access_event_registration_answer_registration | ||
NEW ir.model.access: website_event_questions.access_event_question_answer_registration | ||
# NOTHING TO DO: Extra noupdate=0 records |