-
-
Notifications
You must be signed in to change notification settings - Fork 695
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ab91294
commit 80dd5b3
Showing
3 changed files
with
78 additions
and
1 deletion.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
addons/im_livechat/migrations/13.0.1.0/openupgrade_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,26 @@ | ||
---Models in module 'im_livechat'--- | ||
---Fields in module 'im_livechat'--- | ||
im_livechat / im_livechat.channel / image (binary) : DEL attachment: True | ||
im_livechat / im_livechat.channel / image_128 (binary) : NEW attachment: True, hasdefault | ||
im_livechat / im_livechat.channel / image_medium (binary) : DEL attachment: True | ||
im_livechat / im_livechat.channel / image_small (binary) : DEL attachment: True | ||
# DONE: pre-migration: handled image rename | ||
|
||
im_livechat / im_livechat.channel / rating_ids (one2many) : NEW relation: rating.rating | ||
im_livechat / mail.channel / country_id (many2one) : NEW relation: res.country | ||
im_livechat / res.users / livechat_username (char) : NEW | ||
# NOTHING TO DO (tentative) | ||
|
||
im_livechat / mail.channel / livechat_operator_id (many2one): NEW relation: res.partner | ||
# DONE: pre-migration: filled with the user_ids of im_livechat.channel | ||
|
||
---XML records in module 'im_livechat'--- | ||
NEW im_livechat.channel: im_livechat.im_livechat_channel_data | ||
# DONE: pre-migration: renamed xmlid from website_livechat.im_livechat_channel_data_website is website_livechat is installed | ||
|
||
NEW ir.rule: im_livechat.im_livechat_rule_manager_read_all_mail_channel | ||
NEW ir.ui.view: im_livechat.im_livechat_channel_view_search | ||
NEW ir.ui.view: im_livechat.livechat_email_template (noupdate) | ||
NEW ir.ui.view: im_livechat.res_users_form_view | ||
NEW ir.ui.view: im_livechat.res_users_form_view_simple_modif | ||
# NOTHING TO DO |
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,51 @@ | ||
# Copyright 2020 ForgeFlow <http://www.forgeflow.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
from openupgradelib import openupgrade | ||
|
||
|
||
_field_renames = [ | ||
('im_livechat.channel', 'im_livechat_channel', | ||
'image_medium', 'image_128'), | ||
] | ||
|
||
|
||
def rename_image_attachments(env): | ||
for old, new in [("image_medium", "image_128")]: | ||
openupgrade.logged_query( | ||
env.cr, """ | ||
UPDATE ir_attachment SET res_field = %s | ||
WHERE res_field = %s AND res_model = 'im_livechat.channel'""", | ||
(new, old), | ||
) | ||
|
||
|
||
def fill_mail_channel_livechat_operator_id(env): | ||
# Done in pre-migration to avoid sql constraint | ||
openupgrade.logged_query( | ||
env.cr, """ | ||
ALTER TABLE mail_channel | ||
ADD COLUMN livechat_operator_id integer""", | ||
) | ||
openupgrade.logged_query( | ||
env.cr, """ | ||
UPDATE mail_channel mc | ||
SET livechat_operator_id = ru.partner_id | ||
FROM im_livechat_channel ilc | ||
JOIN im_livechat_channel_im_user ilciu ON ilciu.channel_id = ilc.id | ||
JOIN res_users ru ON ru.id = ilciu.user_id | ||
WHERE mc.livechat_channel_id = ilc.id | ||
AND mc.livechat_operator_id IS NULL""" | ||
) | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
openupgrade.rename_fields(env, _field_renames) | ||
if openupgrade.column_exists( | ||
env.cr, "im_livechat_channel", "website_description"): | ||
openupgrade.rename_xmlids(env.cr, [ | ||
("website_livechat.im_livechat_channel_data_website", | ||
"im_livechat.im_livechat_channel_data"), | ||
]) | ||
rename_image_attachments(env) | ||
fill_mail_channel_livechat_operator_id(env) |
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