summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--addons/calendar/models/calendar.py4
-rw-r--r--addons/gamification/models/challenge.py8
-rw-r--r--addons/gamification/models/goal.py2
-rw-r--r--addons/hr_holidays/models/hr_leave.py2
-rw-r--r--addons/hr_holidays/tests/test_access_rights.py4
-rw-r--r--addons/hr_recruitment/models/hr_recruitment.py2
-rw-r--r--addons/mail/controllers/bus.py2
-rw-r--r--addons/mail/controllers/home.py2
-rw-r--r--addons/mail/models/mail_channel.py8
-rw-r--r--addons/mail/models/mail_thread.py15
-rw-r--r--addons/mail/models/update.py2
-rw-r--r--addons/mail/static/src/js/composers/chatter_composer.js4
-rw-r--r--addons/mail/static/src/js/discuss.js2
-rw-r--r--addons/mail/static/src/js/models/threads/channel.js2
-rw-r--r--addons/mail/static/src/js/models/threads/document_thread.js2
-rw-r--r--addons/mail/static/tests/chatter_tests.js12
-rw-r--r--addons/mail_bot/models/mail_channel.py2
-rw-r--r--addons/portal/controllers/mail.py2
-rw-r--r--addons/project/models/project.py4
-rw-r--r--addons/rating/models/rating_mixin.py6
-rw-r--r--addons/sale/controllers/portal.py2
-rw-r--r--addons/test_mail/tests/test_discuss.py8
-rw-r--r--addons/test_mail/tests/test_mail_channel.py16
-rw-r--r--addons/test_mail/tests/test_mail_gateway.py4
-rw-r--r--addons/test_mail/tests/test_mail_message.py8
-rw-r--r--addons/test_mail/tests/test_message_management.py6
-rw-r--r--addons/test_mail/tests/test_message_post.py28
-rw-r--r--addons/test_mail/tests/test_odoobot.py2
-rw-r--r--addons/test_mail/tests/test_performance.py12
-rw-r--r--addons/test_mass_mailing/tests/test_mail_channel.py2
-rw-r--r--addons/website_blog/models/website_blog.py8
-rw-r--r--addons/website_blog/tests/test_website_blog_flow.py2
-rw-r--r--addons/website_forum/controllers/main.py2
-rw-r--r--addons/website_forum/models/forum.py8
-rw-r--r--addons/website_livechat/models/mail_channel.py2
-rw-r--r--addons/website_slides/models/slide_channel.py8
-rw-r--r--addons/website_slides/models/slide_slide.py2
37 files changed, 101 insertions, 106 deletions
diff --git a/addons/calendar/models/calendar.py b/addons/calendar/models/calendar.py
index 98f25ab908a..97e131702ae 100644
--- a/addons/calendar/models/calendar.py
+++ b/addons/calendar/models/calendar.py
@@ -226,7 +226,7 @@ class Attendee(models.Model):
result = self.write({'state': 'accepted'})
for attendee in self:
if attendee.event_id:
- attendee.event_id.message_post(body=_("%s has accepted invitation") % (attendee.common_name), subtype="calendar.subtype_invitation")
+ attendee.event_id.message_post(body=_("%s has accepted invitation") % (attendee.common_name), subtype_xmlid="calendar.subtype_invitation")
return result
def do_decline(self):
@@ -234,7 +234,7 @@ class Attendee(models.Model):
res = self.write({'state': 'declined'})
for attendee in self:
if attendee.event_id:
- attendee.event_id.message_post(body=_("%s has declined invitation") % (attendee.common_name), subtype="calendar.subtype_invitation")
+ attendee.event_id.message_post(body=_("%s has declined invitation") % (attendee.common_name), subtype_xmlid="calendar.subtype_invitation")
return res
diff --git a/addons/gamification/models/challenge.py b/addons/gamification/models/challenge.py
index 868e46d1fdf..50254967205 100644
--- a/addons/gamification/models/challenge.py
+++ b/addons/gamification/models/challenge.py
@@ -562,13 +562,13 @@ class Challenge(models.Model):
challenge.message_post(
body=body_html,
partner_ids=challenge.mapped('user_ids.partner_id.id'),
- subtype='mail.mt_comment',
+ subtype_xmlid='mail.mt_comment',
email_layout_xmlid='mail.mail_notification_light',
)
if challenge.report_message_group_id:
challenge.report_message_group_id.message_post(
body=body_html,
- subtype='mail.mt_comment')
+ subtype_xmlid='mail.mt_comment')
else:
# generate individual reports
@@ -586,13 +586,13 @@ class Challenge(models.Model):
challenge.message_notify(
body=body_html,
partner_ids=[user.partner_id.id],
- subtype='mail.mt_comment',
+ subtype_xmlid='mail.mt_comment',
email_layout_xmlid='mail.mail_notification_light',
)
if challenge.report_message_group_id:
challenge.report_message_group_id.message_post(
body=body_html,
- subtype='mail.mt_comment',
+ subtype_xmlid='mail.mt_comment',
email_layout_xmlid='mail.mail_notification_light',
)
return challenge.write({'last_report_date': fields.Date.today()})
diff --git a/addons/gamification/models/goal.py b/addons/gamification/models/goal.py
index f78012d236b..80803449897 100644
--- a/addons/gamification/models/goal.py
+++ b/addons/gamification/models/goal.py
@@ -219,7 +219,7 @@ class Goal(models.Model):
self.message_notify(
body=body_html,
partner_ids=[self.user_id.partner_id.id],
- subtype='mail.mt_comment',
+ subtype_xmlid='mail.mt_comment',
email_layout_xmlid='mail.mail_notification_light',
)
diff --git a/addons/hr_holidays/models/hr_leave.py b/addons/hr_holidays/models/hr_leave.py
index b5d5c1a3458..6c05fc2c61e 100644
--- a/addons/hr_holidays/models/hr_leave.py
+++ b/addons/hr_holidays/models/hr_leave.py
@@ -666,7 +666,7 @@ class HolidaysRequest(models.Model):
# Automatic validation should be done in sudo, because user might not have the rights to do it by himself
holiday_sudo.action_validate()
holiday_sudo.message_subscribe(partner_ids=[holiday._get_responsible_for_approval().partner_id.id])
- holiday_sudo.message_post(body=_("The time off has been automatically approved"), subtype="mt_comment") # Message from OdooBot (sudo)
+ holiday_sudo.message_post(body=_("The time off has been automatically approved"), subtype_xmlid="mail.mt_comment") # Message from OdooBot (sudo)
elif not self._context.get('import_file'):
holiday_sudo.activity_update()
return holiday
diff --git a/addons/hr_holidays/tests/test_access_rights.py b/addons/hr_holidays/tests/test_access_rights.py
index 1a8632f51a9..8781548ad27 100644
--- a/addons/hr_holidays/tests/test_access_rights.py
+++ b/addons/hr_holidays/tests/test_access_rights.py
@@ -608,7 +608,7 @@ class TestAccessRightsWrite(TestHrHolidaysAccessRightsCommon):
""" User may communicate on its own leaves, even if validated """
self.employee_leave.with_user(self.user_employee_id).message_post(
body='I haz messaging',
- subtype='mail.mt_comment',
+ subtype_xmlid='mail.mt_comment',
message_type='comment'
)
@@ -616,7 +616,7 @@ class TestAccessRightsWrite(TestHrHolidaysAccessRightsCommon):
self.employee_leave.with_user(self.user_employee_id).message_post(
body='I still haz messaging',
- subtype='mail.mt_comment',
+ subtype_xmlid='mail.mt_comment',
message_type='comment'
)
diff --git a/addons/hr_recruitment/models/hr_recruitment.py b/addons/hr_recruitment/models/hr_recruitment.py
index ad0a2f32e84..2a6fca31b05 100644
--- a/addons/hr_recruitment/models/hr_recruitment.py
+++ b/addons/hr_recruitment/models/hr_recruitment.py
@@ -448,7 +448,7 @@ class Applicant(models.Model):
applicant.job_id.write({'no_of_hired_employee': applicant.job_id.no_of_hired_employee + 1})
applicant.job_id.message_post(
body=_('New Employee %s Hired') % applicant.partner_name if applicant.partner_name else applicant.name,
- subtype="hr_recruitment.mt_job_applicant_hired")
+ subtype_xmlid="hr_recruitment.mt_job_applicant_hired")
applicant.message_post_with_view(
'hr_recruitment.applicant_hired_template',
values={'applicant': applicant},
diff --git a/addons/mail/controllers/bus.py b/addons/mail/controllers/bus.py
index 81f1700987d..ccbe6bdeb5f 100644
--- a/addons/mail/controllers/bus.py
+++ b/addons/mail/controllers/bus.py
@@ -53,7 +53,7 @@ class MailChatController(BusController):
message = mail_channel.with_context(mail_create_nosubscribe=True).message_post(author_id=author_id,
email_from=email_from, body=body,
message_type='comment',
- subtype='mail.mt_comment')
+ subtype_xmlid='mail.mt_comment')
return message and message.id or False
@route(['/mail/chat_history'], type="json", auth="public", cors="*")
diff --git a/addons/mail/controllers/home.py b/addons/mail/controllers/home.py
index b4c4bd5d93d..9d54b6ebd1c 100644
--- a/addons/mail/controllers/home.py
+++ b/addons/mail/controllers/home.py
@@ -27,7 +27,7 @@ def _admin_password_warn(uid):
.message_post(
body=_("Your password is the default (admin)! If this system is exposed to untrusted users it is important to change it immediately for security reasons. I will keep nagging you about it!"),
message_type='comment',
- subtype='mail.mt_comment'
+ subtype_xmlid='mail.mt_comment'
)
class Home(web.Home):
diff --git a/addons/mail/models/mail_channel.py b/addons/mail/models/mail_channel.py
index 2d3c54a9591..f78a415b522 100644
--- a/addons/mail/models/mail_channel.py
+++ b/addons/mail/models/mail_channel.py
@@ -280,7 +280,7 @@ class Channel(models.Model):
if not self.email_send:
notification = _('<div class="o_mail_notification">left <a href="#" class="o_channel_redirect" data-oe-id="%s">#%s</a></div>') % (self.id, self.name,)
# post 'channel left' message as root since the partner just unsubscribed from the channel
- self.sudo().message_post(body=notification, subtype="mail.mt_comment", author_id=partner.id)
+ self.sudo().message_post(body=notification, subtype_xmlid="mail.mt_comment", author_id=partner.id)
return result
def _notify_get_groups(self):
@@ -780,7 +780,7 @@ class Channel(models.Model):
}
else:
notification = _('<div class="o_mail_notification">joined <a href="#" class="o_channel_redirect" data-oe-id="%s">#%s</a></div>') % (channel.id, channel.name,)
- self.message_post(body=notification, message_type="notification", subtype="mail.mt_comment", author_id=partner.id)
+ self.message_post(body=notification, message_type="notification", subtype_xmlid="mail.mt_comment", author_id=partner.id)
# broadcast the channel header to the added partner
self._broadcast(partner_ids)
@@ -861,7 +861,7 @@ class Channel(models.Model):
added = self.action_follow()
if added and self.channel_type == 'channel' and not self.email_send:
notification = _('<div class="o_mail_notification">joined <a href="#" class="o_channel_redirect" data-oe-id="%s">#%s</a></div>') % (self.id, self.name,)
- self.message_post(body=notification, message_type="notification", subtype="mail.mt_comment")
+ self.message_post(body=notification, message_type="notification", subtype_xmlid="mail.mt_comment")
if added and self.moderation_guidelines:
self._send_guidelines(self.env.user.partner_id)
@@ -886,7 +886,7 @@ class Channel(models.Model):
'channel_partner_ids': [(4, self.env.user.partner_id.id)]
})
notification = _('<div class="o_mail_notification">created <a href="#" class="o_channel_redirect" data-oe-id="%s">#%s</a></div>') % (new_channel.id, new_channel.name,)
- new_channel.message_post(body=notification, message_type="notification", subtype="mail.mt_comment")
+ new_channel.message_post(body=notification, message_type="notification", subtype_xmlid="mail.mt_comment")
channel_info = new_channel.channel_info('creation')[0]
self.env['bus.bus'].sendone((self._cr.dbname, 'res.partner', self.env.user.partner_id.id), channel_info)
return channel_info
diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py
index 5e662e9db00..a4abcaae227 100644
--- a/addons/mail/models/mail_thread.py
+++ b/addons/mail/models/mail_thread.py
@@ -1777,7 +1777,7 @@ class MailThread(models.AbstractModel):
def message_post(self, *,
body='', subject=None, message_type='notification',
email_from=None, author_id=None, parent_id=False,
- subtype_id=False, subtype=None, partner_ids=None, channel_ids=None,
+ subtype_xmlid=None, subtype_id=False, partner_ids=None, channel_ids=None,
attachments=None, attachment_ids=None,
add_sign=True, record_name=False,
**kwargs):
@@ -1791,8 +1791,6 @@ class MailThread(models.AbstractModel):
:param int parent_id: handle thread formation
:param int subtype_id: subtype_id of the message, mainly use fore
followers mechanism
- :param int subtype: xmlid that will be used to compute subtype_id
- if subtype_id is not given.
:param list(int) partner_ids: partner_ids to notify
:param list(int) channel_ids: channel_ids to notify
:param list(tuple(str,str), tuple(str,str, dict) or int) attachments : list of attachment tuples in the form
@@ -1814,7 +1812,9 @@ class MailThread(models.AbstractModel):
raise ValueError('message_post should only be call to post message on record. Use message_notify instead')
if 'model' in msg_kwargs or 'res_id' in msg_kwargs:
- raise ValueError("message_post doesn't support model and res_id parameters anymore. Please call message_post on record")
+ raise ValueError("message_post doesn't support model and res_id parameters anymore. Please call message_post on record.")
+ if 'subtype' in kwargs:
+ raise ValueError("message_post doesn't support subtype parameter anymore. Please give a valid subtype_id or subtype_xmlid value instead.")
self = self.with_lang() # add lang to context imediatly since it will be usefull in various flows latter.
@@ -1832,11 +1832,10 @@ class MailThread(models.AbstractModel):
# Find the message's author
author_id, email_from = self._message_compute_author(author_id, email_from, raise_exception=True)
+ if subtype_xmlid:
+ subtype_id = self.env['ir.model.data'].xmlid_to_res_id(subtype_xmlid)
if not subtype_id:
- subtype = subtype or 'mt_note'
- if '.' not in subtype:
- subtype = 'mail.%s' % subtype
- subtype_id = self.env['ir.model.data'].xmlid_to_res_id(subtype)
+ subtype_id = self.env['ir.model.data'].xmlid_to_res_id('mail_mt_note')
# automatically subscribe recipients if asked to
if self._context.get('mail_post_autofollow') and partner_ids:
diff --git a/addons/mail/models/update.py b/addons/mail/models/update.py
index 573709a1377..edf5b4f2ced 100644
--- a/addons/mail/models/update.py
+++ b/addons/mail/models/update.py
@@ -104,7 +104,7 @@ class PublisherWarrantyContract(AbstractModel):
poster = user
for message in result["messages"]:
try:
- poster.message_post(body=message, subtype='mt_comment', partner_ids=[user.partner_id.id])
+ poster.message_post(body=message, subtype_xmlid='mail.mt_comment', partner_ids=[user.partner_id.id])
except Exception:
pass
if result.get('enterprise_info'):
diff --git a/addons/mail/static/src/js/composers/chatter_composer.js b/addons/mail/static/src/js/composers/chatter_composer.js
index 4b20e5b2d25..04a01142ff3 100644
--- a/addons/mail/static/src/js/composers/chatter_composer.js
+++ b/addons/mail/static/src/js/composers/chatter_composer.js
@@ -205,14 +205,14 @@ var ChatterComposer = BasicComposer.extend({
return new Promise(function (resolve, reject) {
self._super().then(function (message) {
message = _.extend(message, {
- subtype: 'mail.mt_comment',
+ subtype_xmlid: 'mail.mt_comment',
message_type: 'comment',
context: _.defaults({}, self.context, session.user_context),
});
// Subtype
if (self.options.isLog) {
- message.subtype = 'mail.mt_note';
+ message.subtype_xmlid = 'mail.mt_note';
}
// Partner_ids
diff --git a/addons/mail/static/src/js/discuss.js b/addons/mail/static/src/js/discuss.js
index 3d8eda911be..0f2b7feff26 100644
--- a/addons/mail/static/src/js/discuss.js
+++ b/addons/mail/static/src/js/discuss.js
@@ -1496,7 +1496,7 @@ var Discuss = AbstractAction.extend({
var self = this;
var options = {};
if (this._selectedMessage) {
- messageData.subtype = this._selectedMessage.isNote() ? 'mail.mt_note': 'mail.mt_comment';
+ messageData.subtype_xmlid = this._selectedMessage.isNote() ? 'mail.mt_note': 'mail.mt_comment';
messageData.subtype_id = false;
messageData.message_type = 'comment';
diff --git a/addons/mail/static/src/js/models/threads/channel.js b/addons/mail/static/src/js/models/threads/channel.js
index 6301018c01f..a47598e3147 100644
--- a/addons/mail/static/src/js/models/threads/channel.js
+++ b/addons/mail/static/src/js/models/threads/channel.js
@@ -443,7 +443,7 @@ var Channel = SearchableThread.extend(ThreadTypingMixin, {
return this._super.apply(this, arguments).then(function (messageData) {
_.extend(messageData, {
message_type: 'comment',
- subtype: 'mail.mt_comment',
+ subtype_xmlid: 'mail.mt_comment',
command: data.command,
});
return self._rpc({
diff --git a/addons/mail/static/src/js/models/threads/document_thread.js b/addons/mail/static/src/js/models/threads/document_thread.js
index cb860b70beb..eefc8f9bd79 100644
--- a/addons/mail/static/src/js/models/threads/document_thread.js
+++ b/addons/mail/static/src/js/models/threads/document_thread.js
@@ -331,7 +331,7 @@ var DocumentThread = Thread.extend({
_.extend(messageData, {
context: data.context,
message_type: data.message_type,
- subtype: data.subtype || "mail.mt_comment",
+ subtype_xmlid: data.subtype_xmlid || "mail.mt_comment",
subtype_id: data.subtype_id,
});
return self._rpc({
diff --git a/addons/mail/static/tests/chatter_tests.js b/addons/mail/static/tests/chatter_tests.js
index d39be2af342..c108738bf94 100644
--- a/addons/mail/static/tests/chatter_tests.js
+++ b/addons/mail/static/tests/chatter_tests.js
@@ -1008,8 +1008,8 @@ QUnit.test('chatter: post, receive and star messages', async function (assert) {
body: args.kwargs.body,
date: "2016-12-20 10:35:40",
id: messageID,
- is_note: args.kwargs.subtype === 'mail.mt_note',
- is_discussion: args.kwargs.subtype === 'mail.mt_comment',
+ is_note: args.kwargs.subtype_xmlid === 'mail.mt_note',
+ is_discussion: args.kwargs.subtype_xmlid === 'mail.mt_comment',
is_notification: false,
is_starred: false,
model: 'partner',
@@ -1403,8 +1403,8 @@ QUnit.test('chatter: post a message and switch in edit mode', async function (as
body: args.kwargs.body,
date: "2016-12-20 10:35:40",
id: 42,
- is_note: args.kwargs.subtype === 'mail.mt_note',
- is_discussion: args.kwargs.subtype === 'mail.mt_comment',
+ is_note: args.kwargs.subtype_xmlid === 'mail.mt_note',
+ is_discussion: args.kwargs.subtype_xmlid === 'mail.mt_comment',
is_starred: false,
model: 'partner',
res_id: 2,
@@ -3061,8 +3061,8 @@ QUnit.test('chatter: suggested partner auto-follow on message post', async funct
body: args.kwargs.body,
date: "2016-12-20 10:35:40",
id: messageID,
- is_note: args.kwargs.subtype === 'mail.mt_note',
- is_discussion: args.kwargs.subtype === 'mail.mt_comment',
+ is_note: args.kwargs.subtype_xmlid === 'mail.mt_note',
+ is_discussion: args.kwargs.subtype_xmlid === 'mail.mt_comment',
is_notification: false,
is_starred: false,
model: 'partner',
diff --git a/addons/mail_bot/models/mail_channel.py b/addons/mail_bot/models/mail_channel.py
index 0fc6c6f056b..8b792780971 100644
--- a/addons/mail_bot/models/mail_channel.py
+++ b/addons/mail_bot/models/mail_channel.py
@@ -24,6 +24,6 @@ class Channel(models.Model):
'name': 'OdooBot'
})
message = _("Hello,<br/>Odoo's chat helps employees collaborate efficiently. I'm here to help you discover its features.<br/><b>Try to send me an emoji :)</b>")
- channel.sudo().message_post(body=message, author_id=odoobot_id, message_type="comment", subtype="mail.mt_comment")
+ channel.sudo().message_post(body=message, author_id=odoobot_id, message_type="comment", subtype_xmlid="mail.mt_comment")
self.env.user.odoobot_state = 'onboarding_emoji'
return channel
diff --git a/addons/portal/controllers/mail.py b/addons/portal/controllers/mail.py
index 63999697ff3..eddf8cb32ce 100644
--- a/addons/portal/controllers/mail.py
+++ b/addons/portal/controllers/mail.py
@@ -86,7 +86,7 @@ def _message_post_helper(res_model, res_id, message, token='', _hash=False, pid=
message_post_args = dict(
body=message,
message_type=kw.pop('message_type', "comment"),
- subtype=kw.pop('subtype', "mt_comment"),
+ subtype_xmlid=kw.pop('subtype_xmlid', "mail.mt_comment"),
author_id=author_id,
**kw
)
diff --git a/addons/project/models/project.py b/addons/project/models/project.py
index e97754be5b8..decb61cc94b 100644
--- a/addons/project/models/project.py
+++ b/addons/project/models/project.py
@@ -930,8 +930,8 @@ class Task(models.Model):
return self.project_id.partner_id
return res
- def rating_apply(self, rate, token=None, feedback=None, subtype=None):
- return super(Task, self).rating_apply(rate, token=token, feedback=feedback, subtype="project.mt_task_rating")
+ def rating_apply(self, rate, token=None, feedback=None, subtype_xmlid=None):
+ return super(Task, self).rating_apply(rate, token=token, feedback=feedback, subtype_xmlid="project.mt_task_rating")
def _rating_get_parent_field_name(self):
return 'project_id'
diff --git a/addons/rating/models/rating_mixin.py b/addons/rating/models/rating_mixin.py
index 77196e80c50..62fa232f12f 100644
--- a/addons/rating/models/rating_mixin.py
+++ b/addons/rating/models/rating_mixin.py
@@ -168,7 +168,7 @@ class RatingMixin(models.AbstractModel):
subtype_id=subtype_id
)
- def rating_apply(self, rate, token=None, feedback=None, subtype=None):
+ def rating_apply(self, rate, token=None, feedback=None, subtype_xmlid=None):
""" Apply a rating given a token. If the current model inherits from
mail.thread mixin, a message is posted on its chatter. User going through
this method should have at least employee rights because of rating
@@ -178,7 +178,7 @@ class RatingMixin(models.AbstractModel):
:param float rate : the rating value to apply
:param string token : access token
:param string feedback : additional feedback
- :param string subtype : xml id of a valid mail.message.subtype
+ :param string subtype_xmlid : xml id of a valid mail.message.subtype
:returns rating.rating record
"""
@@ -194,7 +194,7 @@ class RatingMixin(models.AbstractModel):
self.message_post(
body="<img src='/rating/static/src/img/rating_%s.png' alt=':%s/10' style='width:18px;height:18px;float:left;margin-right: 5px;'/>%s"
% (rate, rate, feedback),
- subtype=subtype or "mail.mt_comment",
+ subtype_xmlid=subtype_xmlid or "mail.mt_comment",
author_id=rating.partner_id and rating.partner_id.id or None # None will set the default author in mail_thread.py
)
if hasattr(self, 'stage_id') and self.stage_id and hasattr(self.stage_id, 'auto_validation_kanban_state') and self.stage_id.auto_validation_kanban_state:
diff --git a/addons/sale/controllers/portal.py b/addons/sale/controllers/portal.py
index 52495a93316..e951dce54b2 100644
--- a/addons/sale/controllers/portal.py
+++ b/addons/sale/controllers/portal.py
@@ -159,7 +159,7 @@ class CustomerPortal(CustomerPortal):
if order_sudo and request.session.get('view_quote_%s' % order_sudo.id) != now and request.env.user.share and access_token:
request.session['view_quote_%s' % order_sudo.id] = now
body = _('Quotation viewed by customer %s') % order_sudo.partner_id.name
- _message_post_helper('sale.order', order_sudo.id, body, token=order_sudo.access_token, message_type='notification', subtype="mail.mt_note")
+ _message_post_helper('sale.order', order_sudo.id, body, token=order_sudo.access_token, message_type='notification', subtype_xmlid="mail.mt_note")
values = {
'sale_order': order_sudo,
diff --git a/addons/test_mail/tests/test_discuss.py b/addons/test_mail/tests/test_discuss.py
index 5667568ead0..e2bda7dc8d9 100644
--- a/addons/test_mail/tests/test_discuss.py
+++ b/addons/test_mail/tests/test_discuss.py
@@ -15,7 +15,7 @@ class TestChatterTweaks(TestMailCommon, TestRecipients):
def test_post_no_subscribe_author(self):
original = self.test_record.message_follower_ids
self.test_record.with_user(self.user_employee).with_context({'mail_create_nosubscribe': True}).message_post(
- body='Test Body', message_type='comment', subtype='mt_comment')
+ body='Test Body', message_type='comment', subtype_xmlid='mail.mt_comment')
self.assertEqual(self.test_record.message_follower_ids.mapped('partner_id'), original.mapped('partner_id'))
self.assertEqual(self.test_record.message_follower_ids.mapped('channel_id'), original.mapped('channel_id'))
@@ -23,7 +23,7 @@ class TestChatterTweaks(TestMailCommon, TestRecipients):
def test_post_no_subscribe_recipients(self):
original = self.test_record.message_follower_ids
self.test_record.with_user(self.user_employee).with_context({'mail_create_nosubscribe': True}).message_post(
- body='Test Body', message_type='comment', subtype='mt_comment', partner_ids=[self.partner_1.id, self.partner_2.id])
+ body='Test Body', message_type='comment', subtype_xmlid='mail.mt_comment', partner_ids=[self.partner_1.id, self.partner_2.id])
self.assertEqual(self.test_record.message_follower_ids.mapped('partner_id'), original.mapped('partner_id'))
self.assertEqual(self.test_record.message_follower_ids.mapped('channel_id'), original.mapped('channel_id'))
@@ -31,7 +31,7 @@ class TestChatterTweaks(TestMailCommon, TestRecipients):
def test_post_subscribe_recipients(self):
original = self.test_record.message_follower_ids
self.test_record.with_user(self.user_employee).with_context({'mail_create_nosubscribe': True, 'mail_post_autofollow': True}).message_post(
- body='Test Body', message_type='comment', subtype='mt_comment', partner_ids=[self.partner_1.id, self.partner_2.id])
+ body='Test Body', message_type='comment', subtype_xmlid='mail.mt_comment', partner_ids=[self.partner_1.id, self.partner_2.id])
self.assertEqual(self.test_record.message_follower_ids.mapped('partner_id'), original.mapped('partner_id') | self.partner_1 | self.partner_2)
self.assertEqual(self.test_record.message_follower_ids.mapped('channel_id'), original.mapped('channel_id'))
@@ -100,7 +100,7 @@ class TestDiscuss(TestMailCommon, TestRecipients):
def test_set_message_done_user(self):
with self.assertSinglePostNotifications([{'partner': self.partner_employee, 'type': 'inbox'}], message_info={'content': 'Test'}):
message = self.test_record.message_post(
- body='Test', message_type='comment', subtype='mail.mt_comment',
+ body='Test', message_type='comment', subtype_xmlid='mail.mt_comment',
partner_ids=[self.user_employee.partner_id.id])
message.with_user(self.user_employee).set_message_done()
self.assertMailNotifications(message, [{'notif': [{'partner': self.partner_employee, 'type': 'inbox', 'is_read': True}]}])
diff --git a/addons/test_mail/tests/test_mail_channel.py b/addons/test_mail/tests/test_mail_channel.py
index 5dadf2690b7..8869ac21442 100644
--- a/addons/test_mail/tests/test_mail_channel.py
+++ b/addons/test_mail/tests/test_mail_channel.py
@@ -149,7 +149,7 @@ class TestChannelFeatures(TestMailCommon):
self.assertEqual(self.test_channel.channel_partner_ids, self.env['res.partner'])
def test_channel_post_nofollow(self):
- self.test_channel.message_post(body='Test', message_type='comment', subtype='mt_comment')
+ self.test_channel.message_post(body='Test', message_type='comment', subtype_xmlid='mail.mt_comment')
self.assertEqual(self.test_channel.message_channel_ids, self.test_channel)
self.assertEqual(self.test_channel.message_partner_ids, self.env['res.partner'])
@@ -168,7 +168,7 @@ class TestChannelFeatures(TestMailCommon):
})
self._join_channel(self.test_channel, self.user_employee.partner_id | self.test_partner | nomail.partner_id)
with self.mock_mail_gateway():
- self.test_channel.message_post(body="Test", message_type='comment', subtype='mt_comment')
+ self.test_channel.message_post(body="Test", message_type='comment', subtype_xmlid='mail.mt_comment')
self.assertSentEmail(self.test_channel.env.user.partner_id, [self.partner_employee, self.test_partner])
@mute_logger('odoo.addons.mail.models.mail_mail', 'odoo.models.unlink')
@@ -178,7 +178,7 @@ class TestChannelFeatures(TestMailCommon):
self.test_channel.write({'email_send': False})
self._join_channel(self.test_channel, self.user_employee.partner_id | self.test_partner)
with self.mock_mail_gateway():
- self.test_channel.message_post(body="Test", message_type='comment', subtype='mt_comment')
+ self.test_channel.message_post(body="Test", message_type='comment', subtype_xmlid='mail.mt_comment')
self.assertNotSentEmail()
self.assertEqual(len(self._mails), 0)
@@ -188,7 +188,7 @@ class TestChannelFeatures(TestMailCommon):
self.test_channel.write({'alias_name': False})
self.test_channel.message_subscribe([self.user_employee.partner_id.id, self.test_partner.id])
with self.mock_mail_gateway():
- self.test_channel.message_post(body="Test", message_type='comment', subtype='mt_comment')
+ self.test_channel.message_post(body="Test", message_type='comment', subtype_xmlid='mail.mt_comment')
self.assertSentEmail(self.test_channel.env.user.partner_id, [self.test_partner])
@mute_logger('odoo.addons.mail.models.mail_mail')
@@ -323,10 +323,10 @@ class TestChannelModeration(TestMailCommon):
self.channel_1._update_moderation_email([email1], 'ban')
self.channel_1._update_moderation_email([email2], 'allow')
- msg_admin = self.channel_1.message_post(message_type='email', subtype='mt_comment', author_id=self.partner_admin.id)
- msg_moderator = self.channel_1.message_post(message_type='comment', subtype='mt_comment', author_id=self.partner_employee.id)
- msg_email1 = self.channel_1.message_post(message_type='comment', subtype='mt_comment', email_from=formataddr(("MyName", email1)))
- msg_email2 = self.channel_1.message_post(message_type='email', subtype='mt_comment', email_from=email2)
+ msg_admin = self.channel_1.message_post(message_type='email', subtype_xmlid='mail.mt_comment', author_id=self.partner_admin.id)
+ msg_moderator = self.channel_1.message_post(message_type='comment', subtype_xmlid='mail.mt_comment', author_id=self.partner_employee.id)
+ msg_email1 = self.channel_1.message_post(message_type='comment', subtype_xmlid='mail.mt_comment', email_from=formataddr(("MyName", email1)))
+ msg_email2 = self.channel_1.message_post(message_type='email', subtype_xmlid='mail.mt_comment', email_from=email2)
msg_notif = self.channel_1.message_post()
messages = self.env['mail.message'].search([('model', '=', 'mail.channel'), ('res_id', '=', self.channel_1.id)])
diff --git a/addons/test_mail/tests/test_mail_gateway.py b/addons/test_mail/tests/test_mail_gateway.py
index 9850243ba7c..d9da245a1e0 100644
--- a/addons/test_mail/tests/test_mail_gateway.py
+++ b/addons/test_mail/tests/test_mail_gateway.py
@@ -626,14 +626,14 @@ class TestMailgateway(TestMailCommon):
record_msg = first_record.message_post(
subject='Discussion',
no_auto_thread=False,
- subtype='mail.mt_comment',
+ subtype_xmlid='mail.mt_comment',
)
self.assertEqual(record_msg.reply_to, formataddr(('%s %s' % (self.user_employee.company_id.name, first_record.name), '%s@%s' % ('catchall.test', 'test.com'))))
mail_msg = first_record.message_post(
subject='Replies to Record',
reply_to='groups@test.com',
no_auto_thread=True,
- subtype='mail.mt_comment',
+ subtype_xmlid='mail.mt_comment',
)
self.assertEqual(mail_msg.reply_to, 'groups@test.com')
diff --git a/addons/test_mail/tests/test_mail_message.py b/addons/test_mail/tests/test_mail_message.py
index 3f433496f4e..4f08f0abc18 100644
--- a/addons/test_mail/tests/test_mail_message.py
+++ b/addons/test_mail/tests/test_mail_message.py
@@ -360,13 +360,13 @@ class TestMessageAccess(TestMailCommon):
).with_context({'mail_create_nosubscribe': False})
# mark all as read clear needactions
- group_private.message_post(body='Test', message_type='comment', subtype='mail.mt_comment', partner_ids=[emp_partner.id])
+ group_private.message_post(body='Test', message_type='comment', subtype_xmlid='mail.mt_comment', partner_ids=[emp_partner.id])
emp_partner.env['mail.message'].mark_all_as_read(domain=[])
na_count = emp_partner.get_needaction_count()
self.assertEqual(na_count, 0, "mark all as read should conclude all needactions")
# mark all as read also clear inaccessible needactions
- new_msg = group_private.message_post(body='Zest', message_type='comment', subtype='mail.mt_comment', partner_ids=[emp_partner.id])
+ new_msg = group_private.message_post(body='Zest', message_type='comment', subtype_xmlid='mail.mt_comment', partner_ids=[emp_partner.id])
needaction_accessible = len(emp_partner.env['mail.message'].search([['needaction', '=', True]]))
self.assertEqual(needaction_accessible, 1, "a new message to a partner is readable to that partner")
@@ -388,13 +388,13 @@ class TestMessageAccess(TestMailCommon):
portal_partner = self.user_portal.partner_id.with_user(self.user_portal)
# mark all as read clear needactions
- self.group_pigs.message_post(body='Test', message_type='comment', subtype='mail.mt_comment', partner_ids=[portal_partner.id])
+ self.group_pigs.message_post(body='Test', message_type='comment', subtype_xmlid='mail.mt_comment', partner_ids=[portal_partner.id])
portal_partner.env['mail.message'].mark_all_as_read(domain=[])
na_count = portal_partner.get_needaction_count()
self.assertEqual(na_count, 0, "mark all as read should conclude all needactions")
# mark all as read also clear inaccessible needactions
- new_msg = self.group_pigs.message_post(body='Zest', message_type='comment', subtype='mail.mt_comment', partner_ids=[portal_partner.id])
+ new_msg = self.group_pigs.message_post(body='Zest', message_type='comment', subtype_xmlid='mail.mt_comment', partner_ids=[portal_partner.id])
needaction_accessible = len(portal_partner.env['mail.message'].search([['needaction', '=', True]]))
self.assertEqual(needaction_accessible, 1, "a new message to a partner is readable to that partner")
diff --git a/addons/test_mail/tests/test_message_management.py b/addons/test_mail/tests/test_message_management.py
index cc3cb367574..b2c437ce2db 100644
--- a/addons/test_mail/tests/test_message_management.py
+++ b/addons/test_mail/tests/test_message_management.py
@@ -36,7 +36,7 @@ class TestMailResend(TestMailCommon):
[{'partner': partner, 'type': 'email', 'status': 'exception'} for partner in self.partners],
message_info={'message_type': 'notification'},
sim_error='connect_failure'):
- message = self.test_record.with_user(self.user_admin).message_post(partner_ids=self.partners.ids, subtype='mail.mt_comment', message_type='notification')
+ message = self.test_record.with_user(self.user_admin).message_post(partner_ids=self.partners.ids, subtype_xmlid='mail.mt_comment', message_type='notification')
wizard = self.env['mail.resend.message'].with_context({'mail_message_to_resend': message.id}).create({})
self.assertEqual(wizard.notification_ids.mapped('res_partner_id'), self.partners, "wizard should manage notifications for each failed partner")
@@ -80,7 +80,7 @@ class TestMailResend(TestMailCommon):
def test_remove_mail_become_canceled(self):
# two failure sent on bus, one for each mail
with self.mock_mail_gateway(), self.assertBus([(self.cr.dbname, 'res.partner', self.partner_admin.id)] * 2):
- message = self.test_record.with_user(self.user_admin).message_post(partner_ids=self.partners.ids, subtype='mail.mt_comment', message_type='notification')
+ message = self.test_record.with_user(self.user_admin).message_post(partner_ids=self.partners.ids, subtype_xmlid='mail.mt_comment', message_type='notification')
self.assertMailNotifications(message, [
{'content': '', 'message_type': 'notification',
@@ -102,7 +102,7 @@ class TestMailResend(TestMailCommon):
@mute_logger('odoo.addons.mail.models.mail_mail')
def test_cancel_all(self):
with self.mock_mail_gateway(), self.assertBus([(self.cr.dbname, 'res.partner', self.partner_admin.id)] * 2):
- message = self.test_record.with_user(self.user_admin).message_post(partner_ids=self.partners.ids, subtype='mail.mt_comment', message_type='notification')
+ message = self.test_record.with_user(self.user_admin).message_post(partner_ids=self.partners.ids, subtype_xmlid='mail.mt_comment', message_type='notification')
wizard = self.env['mail.resend.message'].with_context({'mail_message_to_resend': message.id}).create({})
# one update for cancell
diff --git a/addons/test_mail/tests/test_message_post.py b/addons/test_mail/tests/test_message_post.py
index bf894fafe12..8e0a06320fb 100644
--- a/addons/test_mail/tests/test_message_post.py
+++ b/addons/test_mail/tests/test_message_post.py
@@ -27,7 +27,7 @@ class TestMessagePost(TestMailCommon, TestRecipients):
(self.user_employee | self.user_admin).write({'notification_type': 'inbox'})
with self.assertSinglePostNotifications([{'partner': self.partner_employee, 'type': 'inbox'}], {'content': 'Body'}):
self.test_record.message_post(
- body='Body', message_type='comment', subtype='mail.mt_comment',
+ body='Body', message_type='comment', subtype_xmlid='mail.mt_comment',
partner_ids=[self.user_employee.partner_id.id])
self.test_record.message_subscribe([self.partner_1.id])
@@ -35,14 +35,14 @@ class TestMessagePost(TestMailCommon, TestRecipients):
{'partner': self.partner_employee, 'type': 'inbox'},
{'partner': self.partner_1, 'type': 'email'}], {'content': 'NewBody'}):
self.test_record.message_post(
- body='NewBody', message_type='comment', subtype='mail.mt_comment',
+ body='NewBody', message_type='comment', subtype_xmlid='mail.mt_comment',
partner_ids=[self.user_employee.partner_id.id])
with self.assertSinglePostNotifications([
{'partner': self.partner_1, 'type': 'email'},
{'partner': self.partner_portal, 'type': 'email'}], {'content': 'ToPortal'}):
self.test_record.message_post(
- body='ToPortal', message_type='comment', subtype='mail.mt_comment',
+ body='ToPortal', message_type='comment', subtype_xmlid='mail.mt_comment',
partner_ids=[self.partner_portal.id])
def test_post_inactive_follower(self):
@@ -52,14 +52,14 @@ class TestMessagePost(TestMailCommon, TestRecipients):
self.test_record._message_subscribe(self.user_employee.partner_id.ids)
with self.assertSinglePostNotifications([{'partner': self.partner_employee, 'type': 'inbox'}], {'content': 'Test'}):
self.test_record.message_post(
- body='Test', message_type='comment', subtype='mail.mt_comment')
+ body='Test', message_type='comment', subtype_xmlid='mail.mt_comment')
self.user_employee.active = False
# at this point, partner is still active and would receive an email notification
self.user_employee.partner_id._write({'active': False})
with self.assertPostNotifications([{'content': 'Test', 'notif': []}]):
self.test_record.message_post(
- body='Test', message_type='comment', subtype='mail.mt_comment')
+ body='Test', message_type='comment', subtype_xmlid='mail.mt_comment')
@mute_logger('odoo.addons.mail.models.mail_mail')
def test_post_notifications(self):
@@ -74,7 +74,7 @@ class TestMessagePost(TestMailCommon, TestRecipients):
{'partner': self.partner_admin, 'type': 'email'}], {'content': _body}, mail_unlink_sent=True):
msg = self.test_record.with_user(self.user_employee).message_post(
body=_body, subject=_subject,
- message_type='comment', subtype='mt_comment',
+ message_type='comment', subtype_xmlid='mail.mt_comment',
partner_ids=[self.partner_1.id, self.partner_2.id]
)
@@ -95,7 +95,7 @@ class TestMessagePost(TestMailCommon, TestRecipients):
msg = self.test_record.with_user(self.user_employee).message_post(
body='Test', subject='Test',
- message_type='comment', subtype='mt_comment',
+ message_type='comment', subtype_xmlid='mail.mt_comment',
partner_ids=[self.partner_1.id, self.partner_2.id],
mail_auto_delete=False
)
@@ -126,7 +126,7 @@ class TestMessagePost(TestMailCommon, TestRecipients):
with self.mock_mail_gateway():
msg = self.test_record.with_user(self.user_employee).message_post(
body='Test', subject='Test',
- message_type='comment', subtype='mt_comment',
+ message_type='comment', subtype_xmlid='mail.mt_comment',
attachment_ids=[_attach_1.id, _attach_2.id],
partner_ids=[self.partner_1.id],
attachments=_attachments,
@@ -155,7 +155,7 @@ class TestMessagePost(TestMailCommon, TestRecipients):
with self.mock_mail_gateway():
parent_msg = self.test_record.with_user(self.user_employee).message_post(
body='<p>Test</p>', subject='Test Subject',
- message_type='comment', subtype='mt_comment')
+ message_type='comment', subtype_xmlid='mail.mt_comment')
self.assertEqual(parent_msg.partner_ids, self.env['res.partner'])
self.assertNotSentEmail()
@@ -163,7 +163,7 @@ class TestMessagePost(TestMailCommon, TestRecipients):
with self.assertPostNotifications([{'content': '<p>Test Answer</p>', 'notif': [{'partner': self.partner_1, 'type': 'email'}]}]):
msg = self.test_record.with_user(self.user_employee).message_post(
body='<p>Test Answer</p>',
- message_type='comment', subtype='mt_comment',
+ message_type='comment', subtype_xmlid='mail.mt_comment',
partner_ids=[self.partner_1.id],
parent_id=parent_msg.id)
@@ -177,7 +177,7 @@ class TestMessagePost(TestMailCommon, TestRecipients):
new_msg = self.test_record.with_user(self.user_employee).message_post(
body='<p>Test Answer Bis</p>',
- message_type='comment', subtype='mt_comment',
+ message_type='comment', subtype_xmlid='mail.mt_comment',
parent_id=msg.id)
self.assertEqual(new_msg.parent_id.id, parent_msg.id, 'message_post: flatten error')
@@ -193,7 +193,7 @@ class TestMessagePost(TestMailCommon, TestRecipients):
]), patch.object(MailTestSimple, 'check_access_rights', return_value=True):
new_msg = self.test_record.with_user(self.user_portal).message_post(
body='<p>Test</p>', subject='Subject',
- message_type='comment', subtype='mt_comment')
+ message_type='comment', subtype_xmlid='mail.mt_comment')
self.assertEqual(new_msg.sudo().notified_partner_ids, (self.partner_1 | self.user_employee.partner_id))
@@ -201,14 +201,14 @@ class TestMessagePost(TestMailCommon, TestRecipients):
with self.assertRaises(AccessError):
self.test_record.with_user(self.user_portal).message_post(
body='<p>Test</p>', subject='Subject',
- message_type='comment', subtype='mt_comment')
+ message_type='comment', subtype_xmlid='mail.mt_comment')
@mute_logger('odoo.addons.mail.models.mail_mail', 'odoo.addons.mail.models.mail_thread')
def test_post_internal(self):
self.test_record.message_subscribe([self.user_admin.partner_id.id])
msg = self.test_record.with_user(self.user_employee).message_post(
body='My Body', subject='My Subject',
- message_type='comment', subtype='mt_note')
+ message_type='comment', subtype_xmlid='mail.mt_note')
self.assertEqual(msg.partner_ids, self.env['res.partner'])
self.assertEqual(msg.notified_partner_ids, self.env['res.partner'])
diff --git a/addons/test_mail/tests/test_odoobot.py b/addons/test_mail/tests/test_odoobot.py
index 7766b5244dc..740a0444974 100644
--- a/addons/test_mail/tests/test_odoobot.py
+++ b/addons/test_mail/tests/test_odoobot.py
@@ -22,7 +22,7 @@ class TestOdoobot(TestMailCommon, TestRecipients):
'attachment_ids': [],
'message_type': 'comment',
'partner_ids': [],
- 'subtype': 'mail.mt_comment'
+ 'subtype_xmlid': 'mail.mt_comment'
}
cls.odoobot_ping_body = '<a href="http://odoo.com/web#model=res.partner&amp;id=%s" class="o_mail_redirect" data-oe-id="%s" data-oe-model="res.partner" target="_blank">@OdooBot</a>' % (cls.odoobot.id, cls.odoobot.id)
cls.test_record_employe = cls.test_record.with_user(cls.user_employee)
diff --git a/addons/test_mail/tests/test_performance.py b/addons/test_mail/tests/test_performance.py
index b7948c23a4b..cf9852d6454 100644
--- a/addons/test_mail/tests/test_performance.py
+++ b/addons/test_mail/tests/test_performance.py
@@ -331,7 +331,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
with self.assertQueryCount(__system__=5, emp=6):
record.message_post(
body='<p>Test message_post as log</p>',
- subtype='mail.mt_note',
+ subtype_xmlid='mail.mt_note',
message_type='comment')
@users('__system__', 'emp')
@@ -344,7 +344,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
body='<p>Test Post Performances basic</p>',
partner_ids=[],
message_type='comment',
- subtype='mail.mt_comment')
+ subtype_xmlid='mail.mt_comment')
@mute_logger('odoo.addons.mail.models.mail_mail', 'odoo.models.unlink')
@users('__system__', 'emp')
@@ -357,7 +357,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
body='<p>Test Post Performances with an email ping</p>',
partner_ids=self.customer.ids,
message_type='comment',
- subtype='mail.mt_comment')
+ subtype_xmlid='mail.mt_comment')
@users('__system__', 'emp')
@warmup
@@ -369,7 +369,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
body='<p>Test Post Performances with an inbox ping</p>',
partner_ids=self.user_test.partner_id.ids,
message_type='comment',
- subtype='mail.mt_comment')
+ subtype_xmlid='mail.mt_comment')
@mute_logger('odoo.models.unlink')
@users('__system__', 'emp')
@@ -476,7 +476,7 @@ class TestMailComplexPerformance(BaseMailPerformance):
record.message_post(
body='<p>Test Post Performances</p>',
message_type='comment',
- subtype='mail.mt_comment')
+ subtype_xmlid='mail.mt_comment')
self.assertEqual(record.message_ids[0].body, '<p>Test Post Performances</p>')
self.assertEqual(record.message_ids[0].notified_partner_ids, self.partners | self.user_portal.partner_id)
@@ -823,7 +823,7 @@ class TestMailHeavyPerformancePost(BaseMailPerformance):
body='<p>Test body <img src="cid:cid1"> <img src="cid:cid2"></p>',
subject='Test Subject',
message_type='notification',
- subtype=None,
+ subtype_xmlid=None,
partner_ids=partner_ids,
channel_ids=channel_ids,
parent_id=False,
diff --git a/addons/test_mass_mailing/tests/test_mail_channel.py b/addons/test_mass_mailing/tests/test_mail_channel.py
index b8bcd59d908..c5b903ff94d 100644
--- a/addons/test_mass_mailing/tests/test_mail_channel.py
+++ b/addons/test_mass_mailing/tests/test_mail_channel.py
@@ -40,7 +40,7 @@ class TestChannelPartnersNotification(common.TestMailCommon):
self.test_channel.write({'email_send': True})
self._join_channel(self.test_channel, self.test_partner)
with self.mock_mail_gateway():
- self.test_channel.message_post(body="Test", message_type='comment', subtype='mt_comment')
+ self.test_channel.message_post(body="Test", message_type='comment', subtype_xmlid='mail.mt_comment')
self.assertEqual(len(self._mails), 1, 'Number of mail incorrect. Should be equal to 1.')
for email in self._mails:
diff --git a/addons/website_blog/models/website_blog.py b/addons/website_blog/models/website_blog.py
index 47bff0f31aa..690d62a799c 100644
--- a/addons/website_blog/models/website_blog.py
+++ b/addons/website_blog/models/website_blog.py
@@ -37,7 +37,7 @@ class Blog(models.Model):
return res
@api.returns('mail.message', lambda value: value.id)
- def message_post(self, *, parent_id=False, subtype=None, **kwargs):
+ def message_post(self, *, parent_id=False, subtype_id=False, **kwargs):
""" Temporary workaround to avoid spam. If someone replies on a channel
through the 'Presentation Published' email, it should be considered as a
note as we don't want all channel followers to be notified of this answer. """
@@ -45,10 +45,8 @@ class Blog(models.Model):
if parent_id:
parent_message = self.env['mail.message'].sudo().browse(parent_id)
if parent_message.subtype_id and parent_message.subtype_id == self.env.ref('website_blog.mt_blog_blog_published'):
- if kwargs.get('subtype_id'):
- kwargs['subtype_id'] = False
- subtype = 'mail.mt_note'
- return super(Blog, self).message_post(parent_id=parent_id, subtype=subtype, **kwargs)
+ subtype_id = self.env.ref('mail.mt_note').id
+ return super(Blog, self).message_post(parent_id=parent_id, subtype_id=subtype_id, **kwargs)
def all_tags(self, join=False, min_limit=1):
BlogTag = self.env['blog.tag']
diff --git a/addons/website_blog/tests/test_website_blog_flow.py b/addons/website_blog/tests/test_website_blog_flow.py
index 0bca765d48c..d53bc8f7dc4 100644
--- a/addons/website_blog/tests/test_website_blog_flow.py
+++ b/addons/website_blog/tests/test_website_blog_flow.py
@@ -53,7 +53,7 @@ class TestWebsiteBlogFlow(TestWebsiteBlogCommon):
body='Armande BlogUser Commented',
message_type='comment',
author_id=self.user_employee.partner_id.id,
- subtype='mt_comment',
+ subtype_xmlid='mail.mt_comment',
)
self.assertIn(
self.user_employee.partner_id, test_blog_post.message_partner_ids,
diff --git a/addons/website_forum/controllers/main.py b/addons/website_forum/controllers/main.py
index d0f47befb7b..31606e41a9a 100644
--- a/addons/website_forum/controllers/main.py
+++ b/addons/website_forum/controllers/main.py
@@ -329,7 +329,7 @@ class WebsiteForum(WebsiteProfile):
post.with_context(mail_create_nosubscribe=True).message_post(
body=body,
message_type='comment',
- subtype='mt_comment')
+ subtype_xmlid='mail.mt_comment')
return werkzeug.utils.redirect("/forum/%s/question/%s" % (slug(forum), slug(question)))
@http.route('/forum/<model("forum.forum"):forum>/post/<model("forum.post"):post>/toggle_correct', type='json', auth="public", website=True)
diff --git a/addons/website_forum/models/forum.py b/addons/website_forum/models/forum.py
index f3738eb07e2..b21845bfd92 100644
--- a/addons/website_forum/models/forum.py
+++ b/addons/website_forum/models/forum.py
@@ -497,12 +497,12 @@ class Post(models.Model):
if 'content' in vals or 'name' in vals:
for post in self:
if post.parent_id:
- body, subtype = _('Answer Edited'), 'website_forum.mt_answer_edit'
+ body, subtype_xmlid = _('Answer Edited'), 'website_forum.mt_answer_edit'
obj_id = post.parent_id
else:
- body, subtype = _('Question Edited'), 'website_forum.mt_question_edit'
+ body, subtype_xmlid = _('Question Edited'), 'website_forum.mt_question_edit'
obj_id = post
- obj_id.message_post(body=body, subtype=subtype)
+ obj_id.message_post(body=body, subtype_xmlid=subtype_xmlid)
if 'active' in vals:
answers = self.env['forum.post'].with_context(active_test=False).search([('parent_id', 'in', self.ids)])
if answers:
@@ -717,7 +717,7 @@ class Post(models.Model):
'email_from': self_sudo.create_uid.email_formatted, # use sudo here because of access to res.users model
'body': tools.html_sanitize(self.content, sanitize_attributes=True, strip_style=True, strip_classes=True),
'message_type': 'comment',
- 'subtype': 'mail.mt_comment',
+ 'subtype_xmlid': 'mail.mt_comment',
'date': self.create_date,
}
new_message = question.with_context(mail_create_nosubscribe=True).message_post(**values)
diff --git a/addons/website_livechat/models/mail_channel.py b/addons/website_livechat/models/mail_channel.py
index 5f3b05b2ccd..6f0ddee0fc7 100644
--- a/addons/website_livechat/models/mail_channel.py
+++ b/addons/website_livechat/models/mail_channel.py
@@ -69,7 +69,7 @@ class MailChannel(models.Model):
message = _('has left the conversation.')
leave_message = '%s %s' % (name, message)
self.message_post(author_id=self.env.ref('base.user_root').sudo().partner_id.id,
- body=leave_message, message_type='comment', subtype='mt_comment')
+ body=leave_message, message_type='comment', subtype_xmlid='mail.mt_comment')
def message_post(self, **kwargs):
"""Override to mark the visitor as still connected.
diff --git a/addons/website_slides/models/slide_channel.py b/addons/website_slides/models/slide_channel.py
index 77aacea09d9..90fa7898eb9 100644
--- a/addons/website_slides/models/slide_channel.py
+++ b/addons/website_slides/models/slide_channel.py
@@ -398,7 +398,7 @@ class Channel(models.Model):
return res
@api.returns('mail.message', lambda value: value.id)
- def message_post(self, *, parent_id=False, subtype=None, **kwargs):
+ def message_post(self, *, parent_id=False, subtype_id=False, **kwargs):
""" Temporary workaround to avoid spam. If someone replies on a channel
through the 'Presentation Published' email, it should be considered as a
note as we don't want all channel followers to be notified of this answer. """
@@ -408,10 +408,8 @@ class Channel(models.Model):
if parent_id:
parent_message = self.env['mail.message'].sudo().browse(parent_id)
if parent_message.subtype_id and parent_message.subtype_id == self.env.ref('website_slides.mt_channel_slide_published'):
- if kwargs.get('subtype_id'):
- kwargs['subtype_id'] = False
- subtype = 'mail.mt_note'
- return super(Channel, self).message_post(parent_id=parent_id, subtype=subtype, **kwargs)
+ subtype_id = self.env.ref('mail.mt_note').id
+ return super(Channel, self).message_post(parent_id=parent_id, subtype_id=subtype_id, **kwargs)
# ---------------------------------------------------------
# Business / Actions
diff --git a/addons/website_slides/models/slide_slide.py b/addons/website_slides/models/slide_slide.py
index 9e0730a1abb..57a40d140af 100644
--- a/addons/website_slides/models/slide_slide.py
+++ b/addons/website_slides/models/slide_slide.py
@@ -483,7 +483,7 @@ class Slide(models.Model):
slide.channel_id.with_context(mail_create_nosubscribe=True).message_post(
subject=subject,
body=html_body,
- subtype='website_slides.mt_channel_slide_published',
+ subtype_xmlid='website_slides.mt_channel_slide_published',
email_layout_xmlid='mail.mail_notification_light',
)
return True