Skip to content

Commit b5e9663

Browse files
committed
Merge PR #4832 into 18.0
Signed-off-by MiquelRForgeFlow
2 parents 606ffaa + 72290ee commit b5e9663

File tree

7 files changed

+338
-1
lines changed

7 files changed

+338
-1
lines changed

docsource/modules170-180.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ Module coverage 17.0 -> 18.0
642642
+---------------------------------------------------+----------------------+-------------------------------------------------+
643643
| lunch | | |
644644
+---------------------------------------------------+----------------------+-------------------------------------------------+
645-
| mail | | |
645+
| mail | |Done |
646646
+---------------------------------------------------+----------------------+-------------------------------------------------+
647647
| mail_bot | | |
648648
+---------------------------------------------------+----------------------+-------------------------------------------------+

openupgrade_scripts/apriori.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
# only used here for upgrade_analysis
2424
renamed_models = {
2525
# odoo
26+
# mail
27+
"mail.notification.web.push": "web.push",
28+
"mail.partner.device": "mail.push.device",
29+
"mail.shortcode": "mail.canned.response",
2630
# OCA/...
2731
}
2832

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Copyright 2025 Hunki Enterprises BV
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from openupgradelib import openupgrade
5+
6+
7+
def discuss_channel_last_interest(env):
8+
"""
9+
Set last interest date of channel from newest message posted
10+
"""
11+
openupgrade.logged_query(
12+
env.cr,
13+
"""
14+
UPDATE discuss_channel
15+
SET last_interest_dt=mail_message.create_date
16+
FROM
17+
(
18+
SELECT res_id, max(create_date) create_date
19+
FROM mail_message
20+
WHERE model='discuss.channel'
21+
GROUP BY res_id
22+
) mail_message
23+
WHERE mail_message.res_id=discuss_channel.id
24+
""",
25+
)
26+
27+
28+
def discuss_channel_member_new_message_separator(env):
29+
"""
30+
Set new_message_separator to the id of the first message after last_interest_id
31+
"""
32+
openupgrade.logged_query(
33+
env.cr,
34+
"""
35+
UPDATE discuss_channel_member
36+
SET new_message_separator=COALESCE(mail_message.id, 0)
37+
FROM
38+
(
39+
SELECT res_id, min(mail_message.id) id
40+
FROM mail_message
41+
JOIN discuss_channel
42+
ON discuss_channel.id=mail_message.res_id
43+
AND mail_message.model='discuss.channel'
44+
JOIN discuss_channel_member
45+
ON discuss_channel_member.channel_id=discuss_channel.id
46+
WHERE
47+
mail_message.create_date > discuss_channel_member.last_interest_dt
48+
GROUP BY mail_message.res_id
49+
) mail_message
50+
WHERE
51+
discuss_channel_member.channel_id=mail_message.res_id
52+
""",
53+
)
54+
55+
56+
def discuss_channel_member_unpin_dt(env):
57+
"""
58+
Set to now if v17 is_pinned has been unset
59+
"""
60+
openupgrade.logged_query(
61+
env.cr,
62+
"""
63+
UPDATE discuss_channel_member
64+
SET unpin_dt=CURRENT_TIMESTAMP
65+
WHERE not is_pinned
66+
""",
67+
)
68+
69+
70+
@openupgrade.migrate()
71+
def migrate(env, version):
72+
openupgrade.load_data(env, "mail", "18.0.1.18/noupdate_changes.xml")
73+
discuss_channel_last_interest(env)
74+
discuss_channel_member_new_message_separator(env)
75+
discuss_channel_member_unpin_dt(env)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright 2025 Hunki Enterprises BV
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from openupgradelib import openupgrade
5+
6+
model_renames = [
7+
("mail.notification.web.push", "web.push"),
8+
("mail.partner.device", "mail.push.device"),
9+
("mail.shortcode", "mail.canned.response"),
10+
]
11+
12+
table_renames = [
13+
("mail_notification_web_push", "web_push"),
14+
("mail_partner_device", "mail_push_device"),
15+
("mail_shortcode", "mail_canned_response"),
16+
]
17+
18+
field_renames = [
19+
("web.push", "web_push", "user_device", "mail_push_device_id"),
20+
]
21+
22+
23+
@openupgrade.migrate()
24+
def migrate(env, version):
25+
openupgrade.rename_models(env.cr, model_renames)
26+
openupgrade.rename_tables(env.cr, table_renames)
27+
openupgrade.rename_fields(env, field_renames)
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
---Models in module 'mail'---
2+
obsolete model mail.notification.web.push
3+
4+
DONE: renamed to web.push
5+
6+
obsolete model mail.partner.device
7+
8+
DONE: renamed to mail.push.device
9+
10+
obsolete model mail.shortcode
11+
12+
DONE: renamed to mail.canned.response
13+
14+
new model mail.canned.response
15+
16+
DONE: renamed from mail.shortcode
17+
18+
new model mail.push
19+
20+
DONE: renamed from mail.notification.web.push
21+
22+
new model mail.push.device
23+
24+
DONE: renamed from mail.push.device
25+
26+
new model mail.scheduled.message
27+
28+
NOTHING TO DO
29+
30+
---Fields in module 'mail'---
31+
mail / discuss.channel / from_message_id (many2one) : NEW relation: mail.message
32+
33+
# NOTHING TO DO: start message for subchannel, new functionality
34+
35+
mail / discuss.channel / last_interest_dt (datetime) : NEW
36+
37+
# DONE: filled from date of last message
38+
39+
mail / discuss.channel / parent_channel_id (many2one) : NEW relation: discuss.channel
40+
mail / discuss.channel / sub_channel_ids (one2many) : NEW relation: discuss.channel
41+
42+
# NOTHING TO DO: new functionality
43+
44+
mail / discuss.channel.member / custom_notifications (selection): selection_keys is now '['all', 'mentions', 'no_notif']' ('['mentions', 'no_notif']')
45+
46+
# NOTHING TO DO: added value
47+
48+
mail / discuss.channel.member / is_minimized (boolean) : DEL
49+
50+
# NOTHING TO DO
51+
52+
mail / discuss.channel.member / is_pinned (boolean) : not stored anymore
53+
mail / discuss.channel.member / is_pinned (boolean) : now a function
54+
55+
# DONE: see unpin_dt below
56+
57+
mail / discuss.channel.member / new_message_separator (integer): NEW required, hasdefault: default
58+
59+
# DONE: set to the id of the first message older than last_interest_dt
60+
61+
mail / discuss.channel.member / unpin_dt (datetime) : NEW
62+
63+
# DONE: set to now if v17 is_pinned has been unset
64+
65+
mail / ir.actions.act_window.view / view_mode (False) : selection_keys is now '['activity', 'calendar', 'form', 'graph', 'hierarchy', 'kanban', 'list', 'pivot']' ('['activity', 'calendar', 'form', 'gantt', 'graph', 'hierarchy', 'kanban', 'pivot', 'tree']')
66+
mail / ir.ui.view / type (False) : selection_keys is now '['activity', 'calendar', 'form', 'graph', 'hierarchy', 'kanban', 'list', 'pivot', 'qweb', 'search']' ('['activity', 'calendar', 'form', 'gantt', 'graph', 'hierarchy', 'kanban', 'pivot', 'qweb', 'search', 'tree']')
67+
mail / mail.activity / user_tz (selection) : NEW selection_keys: function, isrelated: related, stored
68+
69+
# NOTHING TO DO: change comes from base
70+
71+
mail / mail.activity.plan.template / delay_count (integer) : NEW hasdefault: default
72+
mail / mail.activity.plan.template / delay_from (selection) : NEW required, selection_keys: ['after_plan_date', 'before_plan_date'], hasdefault: default
73+
mail / mail.activity.plan.template / delay_unit (selection) : NEW required, selection_keys: ['days', 'months', 'weeks'], hasdefault: default
74+
75+
# NOTHING TO DO: new functionality
76+
77+
mail / mail.canned.response / description (char) : NEW
78+
mail / mail.canned.response / group_ids (many2many) : NEW relation: res.groups
79+
mail / mail.canned.response / is_shared (boolean) : NEW isfunction: function, stored
80+
mail / mail.canned.response / last_used (datetime) : NEW
81+
mail / mail.canned.response / source (char) : NEW required
82+
mail / mail.canned.response / substitution (text) : NEW required
83+
84+
# NOTHING TO DO: field from renamed mail.shortcode/new functionality
85+
86+
mail / mail.link.preview / is_hidden (boolean) : NEW
87+
88+
# NOTHING TO DO: new funcitonality
89+
90+
mail / mail.notification.web.push / payload (text) : DEL
91+
mail / mail.notification.web.push / user_device (many2one) : DEL relation: mail.partner.device, required
92+
93+
# NOTHING TO DO: model was renamed to mail.push
94+
95+
mail / mail.partner.device / endpoint (char) : DEL required
96+
mail / mail.partner.device / expiration_time (datetime) : DEL
97+
mail / mail.partner.device / keys (char) : DEL required
98+
mail / mail.partner.device / partner_id (many2one) : DEL relation: res.partner, required
99+
100+
# NOTHING TO DO: model was renamed to mail.push.device
101+
102+
mail / mail.push / mail_push_device_id (many2one): NEW relation: mail.push.device, required
103+
104+
# DONE: renamed from mail.notification.web.push#user_device
105+
106+
mail / mail.push / payload (text) : NEW
107+
108+
# NOTHING TO DO
109+
110+
mail / mail.push.device / endpoint (char) : NEW required
111+
mail / mail.push.device / expiration_time (datetime) : NEW
112+
mail / mail.push.device / keys (char) : NEW required
113+
mail / mail.push.device / partner_id (many2one) : NEW relation: res.partner, required, hasdefault: default
114+
115+
# NOTHING TO DO: model was renamed from mail.partner.device
116+
117+
mail / mail.scheduled.message / attachment_ids (many2many) : NEW relation: ir.attachment
118+
mail / mail.scheduled.message / author_id (many2one) : NEW relation: res.partner, required
119+
mail / mail.scheduled.message / body (html) : NEW
120+
mail / mail.scheduled.message / is_note (boolean) : NEW hasdefault: default
121+
mail / mail.scheduled.message / model (char) : NEW required
122+
mail / mail.scheduled.message / notification_parameters (text): NEW
123+
mail / mail.scheduled.message / partner_ids (many2many) : NEW relation: res.partner
124+
mail / mail.scheduled.message / res_id (many2one_reference) : NEW relation: model, required
125+
mail / mail.scheduled.message / scheduled_date (datetime) : NEW required
126+
mail / mail.scheduled.message / subject (char) : NEW
127+
128+
# NOTHING TO DO: new functionality
129+
130+
mail / mail.shortcode / description (char) : DEL
131+
mail / mail.shortcode / last_used (datetime) : DEL
132+
mail / mail.shortcode / source (char) : DEL required
133+
mail / mail.shortcode / substitution (text) : DEL required
134+
135+
# NOTHING TO DO: model was renamed to mail.canned.response
136+
137+
mail / res.users.settings / channel_notifications (selection): NEW selection_keys: ['all', 'no_notif']
138+
mail / res.users.settings / mute_until_dt (datetime) : NEW
139+
140+
# NOTHING TO DO: new functionality
141+
142+
---XML records in module 'mail'---
143+
NEW discuss.channel: mail.channel_admin (noupdate)
144+
NEW ir.actions.act_window: mail.mail_activity_action_my
145+
NEW ir.actions.act_window: mail.mail_canned_response_action
146+
DEL ir.actions.act_window: mail.mail_shortcode_action
147+
NEW ir.actions.act_window.view: mail.mail_activity_action_my_view_kanban
148+
NEW ir.actions.act_window.view: mail.mail_activity_action_my_view_tree
149+
NEW ir.actions.client: mail.discuss_call_settings_action
150+
NEW ir.actions.client: mail.discuss_notification_settings_action
151+
NEW ir.config_parameter: mail.restrict_template_rendering (noupdate)
152+
NEW ir.cron: mail.ir_cron_discuss_users_settings_unmute (noupdate)
153+
NEW ir.cron: mail.ir_cron_post_scheduled_message (noupdate)
154+
NEW ir.model.access: mail.access_mail_canned_reponse
155+
NEW ir.model.access: mail.access_mail_push_device_system
156+
NEW ir.model.access: mail.access_mail_push_system
157+
NEW ir.model.access: mail.access_mail_scheduled_message
158+
DEL ir.model.access: mail.access_mail_compose_message_portal
159+
DEL ir.model.access: mail.access_mail_notification_web_push
160+
DEL ir.model.access: mail.access_mail_partner_device
161+
DEL ir.model.access: mail.access_mail_shortcode
162+
DEL ir.model.access: mail.access_mail_shortcode_portal
163+
NEW ir.model.constraint: mail.constraint_discuss_channel_from_message_id_unique
164+
NEW ir.model.constraint: mail.constraint_discuss_channel_sub_channel_no_group_public_id
165+
NEW ir.model.constraint: mail.constraint_mail_push_device_endpoint_unique
166+
DEL ir.model.constraint: mail.constraint_mail_partner_device_endpoint_unique
167+
NEW ir.module.category: mail.module_category_canned_response (noupdate)
168+
NEW ir.rule: mail.ir_rule_mail_canned_response_admin (noupdate)
169+
NEW ir.rule: mail.ir_rule_mail_canned_response_user_read (noupdate)
170+
NEW ir.rule: mail.ir_rule_mail_canned_response_user_update (noupdate)
171+
NEW ir.rule: mail.ir_rule_mail_scheduled_message_user (noupdate)
172+
NEW ir.ui.menu: mail.menu_call_settings
173+
NEW ir.ui.menu: mail.menu_canned_responses
174+
NEW ir.ui.menu: mail.menu_configuration
175+
NEW ir.ui.menu: mail.menu_mail_activities_section
176+
NEW ir.ui.menu: mail.menu_notification_settings
177+
NEW ir.ui.view: mail.mail_activity_plan_view_kanban
178+
NEW ir.ui.view: mail.mail_activity_plan_view_tree_detailed
179+
NEW ir.ui.view: mail.mail_activity_type_view_kanban
180+
NEW ir.ui.view: mail.mail_activity_view_kanban_open_target
181+
NEW ir.ui.view: mail.mail_activity_view_tree_open_target
182+
NEW ir.ui.view: mail.mail_attachment_links
183+
NEW ir.ui.view: mail.mail_canned_response_view_form
184+
NEW ir.ui.view: mail.mail_canned_response_view_search
185+
NEW ir.ui.view: mail.mail_canned_response_view_tree
186+
NEW ir.ui.view: mail.mail_message_subtype_view_search
187+
NEW ir.ui.view: mail.mail_notification_invite
188+
NEW ir.ui.view: mail.mail_scheduled_message_view_form
189+
DEL ir.ui.view: mail.mail_shortcode_view_form
190+
DEL ir.ui.view: mail.mail_shortcode_view_search
191+
DEL ir.ui.view: mail.mail_shortcode_view_tree
192+
NEW mail.canned.response: mail.mail_canned_response_data_hello (noupdate)
193+
NEW res.groups: mail.group_mail_canned_response_admin (noupdate)
194+
NEW web_tour.tour: mail.discuss_channel_tour
195+
196+
# NOTHING TO DO
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
env = locals().get("env")
2+
# new message in employee channel
3+
env.ref("mail.channel_all_employees").message_post(
4+
body="test",
5+
subject="This message should become demo's new_message_separator",
6+
)
7+
env.cr.commit()
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from odoo.tests import TransactionCase
2+
3+
from odoo.addons.openupgrade_framework import openupgrade_test
4+
5+
6+
@openupgrade_test
7+
class TestBaseMigration(TransactionCase):
8+
def test_new_message_separator(self):
9+
"""
10+
Test that discuss channel members get correct new_message_separator
11+
"""
12+
channel_member_demo = self.env["discuss.channel.member"].search(
13+
[
14+
("partner_id", "=", self.env.ref("base.user_demo").partner_id.id),
15+
("channel_id", "=", self.env.ref("mail.channel_all_employees").id),
16+
]
17+
)
18+
message = self.env["mail.message"].search(
19+
[
20+
(
21+
"subject",
22+
"=",
23+
"This message should become demo's new_message_separator",
24+
),
25+
]
26+
)
27+
self.assertTrue(message)
28+
self.assertEqual(channel_member_demo.new_message_separator, message.id)

0 commit comments

Comments
 (0)