diff --git a/addons/mail/models/discuss/discuss_channel.py b/addons/mail/models/discuss/discuss_channel.py
index 7097ba61d04..645db447d50 100644
--- a/addons/mail/models/discuss/discuss_channel.py
+++ b/addons/mail/models/discuss/discuss_channel.py
@@ -271,7 +271,7 @@ class Channel(models.Model):
if 'channel_type' in vals:
failing_channels = self.sudo().filtered(lambda channel: channel.channel_type != vals.get('channel_type'))
if failing_channels:
- raise UserError(_('Cannot change the channel type of: %(channel_names)s'), channel_names=', '.join(failing_channels.mapped('name')))
+ raise UserError(_('Cannot change the channel type of: %(channel_names)s', channel_names=', '.join(failing_channels.mapped('name'))))
result = super().write(vals)
if vals.get('group_ids'):
self._subscribe_users_automatically()
@@ -1033,7 +1033,8 @@ class Channel(models.Model):
for channel in self:
if not channel.message_ids.ids:
return
- if channel.channel_type != 'chat':
+ # a bit not-modular but helps understanding code
+ if channel.channel_type not in {'chat', 'whatsapp'}:
return
last_message_id = channel.message_ids.ids[0] # zero is the index of the last message
member = self.env['discuss.channel.member'].search([('channel_id', '=', channel.id), ('partner_id', '=', self.env.user.partner_id.id)], limit=1)
diff --git a/addons/mail/models/discuss/res_partner.py b/addons/mail/models/discuss/res_partner.py
index ea5c086be42..61b77b5caeb 100644
--- a/addons/mail/models/discuss/res_partner.py
+++ b/addons/mail/models/discuss/res_partner.py
@@ -27,10 +27,10 @@ class ResPartner(models.Model):
("channel_partner_ids", "in", [self.id]),
]
)
- # get the pinned direct messages
+ # get the pinned direct messages (directly include whatsapp to avoid overrides)
channels |= self.env["discuss.channel"].search(
[
- ("channel_type", "=", "chat"),
+ ("channel_type", "in", ["chat", "whatsapp"]),
(
"channel_member_ids",
"in",
diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py
index 2e424380c37..145065894bd 100644
--- a/addons/mail/models/mail_thread.py
+++ b/addons/mail/models/mail_thread.py
@@ -2570,6 +2570,7 @@ class MailThread(models.AbstractModel):
body='', subject=False,
author_id=None, email_from=None,
message_type='notification',
+ partner_ids=False,
attachment_ids=False, tracking_value_ids=False):
""" Shortcut allowing to post note on a document. See ``_message_log_batch``
for more details. """
@@ -2579,12 +2580,14 @@ class MailThread(models.AbstractModel):
{self.id: body}, subject=subject,
author_id=author_id, email_from=email_from,
message_type=message_type,
+ partner_ids=partner_ids,
attachment_ids=attachment_ids, tracking_value_ids=tracking_value_ids
)
def _message_log_batch(self, bodies, subject=False,
author_id=None, email_from=None,
message_type='notification',
+ partner_ids=False,
attachment_ids=False, tracking_value_ids=False):
""" Shortcut allowing to post notes on a batch of documents. It does not
perform any notification and pre-computes some values to have a short code
@@ -2594,7 +2597,9 @@ class MailThread(models.AbstractModel):
access rights are already granted to avoid privilege escalation.
:param bodies: dict {record_id: body}
-
+ :param list partner_ids: optional partners, not used in any notification
+ mechanism. This is mainly used to link a log to a specific customer
+ like SMS or WhatsApp log;
:return: created messages (as sudo)
"""
# protect against side-effect prone usage
@@ -2620,6 +2625,7 @@ class MailThread(models.AbstractModel):
# recipients
'email_add_signature': False, # False as no notification -> no need to compute signature
'message_id': tools.generate_tracking_message_id('message-notify'), # why? this is all but a notify
+ 'partner_ids': partner_ids,
'reply_to': self.env['mail.thread']._notify_get_reply_to(default=email_from)[False],
}
@@ -2713,7 +2719,7 @@ class MailThread(models.AbstractModel):
# Avoid warnings about non-existing fields
for x in ('from', 'to', 'cc', 'canned_response_ids'):
create_values.pop(x, None)
- create_values['partner_ids'] = [Command.link(pid) for pid in create_values.get('partner_ids', [])]
+ create_values['partner_ids'] = [Command.link(pid) for pid in (create_values.get('partner_ids') or [])]
create_values_list.append(create_values)
# remove context, notably for default keys, as this thread method is not
diff --git a/addons/mail/static/src/core/common/composer.js b/addons/mail/static/src/core/common/composer.js
index 8cf6ddd3281..b8a80bdb854 100644
--- a/addons/mail/static/src/core/common/composer.js
+++ b/addons/mail/static/src/core/common/composer.js
@@ -122,18 +122,9 @@ export class Composer extends Component {
});
this.suggestion = this.store.user ? useSuggestion() : undefined;
this.markEventHandled = markEventHandled;
+ this.onDropFile = this.onDropFile.bind(this);
if (this.props.dropzoneRef && this.allowUpload) {
- useDropzone(
- this.props.dropzoneRef,
- (ev) => {
- if (isDragSourceExternalFile(ev.dataTransfer)) {
- for (const file of ev.dataTransfer.files) {
- this.attachmentUploader.uploadFile(file);
- }
- }
- },
- "o-mail-Composer-dropzone"
- );
+ useDropzone(this.props.dropzoneRef, this.onDropFile, "o-mail-Composer-dropzone");
}
if (this.props.messageEdition) {
this.props.messageEdition.composerOfThread = this;
@@ -354,6 +345,14 @@ export class Composer extends Component {
}
}
+ onDropFile(ev) {
+ if (isDragSourceExternalFile(ev.dataTransfer)) {
+ for (const file of ev.dataTransfer.files) {
+ this.attachmentUploader.uploadFile(file);
+ }
+ }
+ }
+
/**
* This doesn't work on firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1699743
*/
diff --git a/addons/mail/static/src/core/web/chatter.xml b/addons/mail/static/src/core/web/chatter.xml
index ea644c09d7e..2a56b5141ed 100644
--- a/addons/mail/static/src/core/web/chatter.xml
+++ b/addons/mail/static/src/core/web/chatter.xml
@@ -21,7 +21,7 @@
Log note