summaryrefslogtreecommitdiff
path: root/addons/mail
diff options
context:
space:
mode:
authorJérome Maes <jem@openerp.com>2015-08-10 16:23:44 +0200
committerAaron Bohy <aab@odoo.com>2015-09-01 20:16:09 +0200
commit95b97d1010e2596c8dbe719382c77c6009819afa (patch)
tree2a5d3b0400785eab023ec1c7768829482682cf24 /addons/mail
parent1d54858cbdd10dd6fbfbb3edc1e032317e2ba3f6 (diff)
[REF] im_livechat : refactoring, make it compatbile with the nw mail module, change reporting sql view (split them in 2), adapt view, ...
Diffstat (limited to 'addons/mail')
-rw-r--r--addons/mail/models/mail_channel.py26
-rw-r--r--addons/mail/static/src/js/mail_chat_backend.js1
-rw-r--r--addons/mail/static/src/js/mail_chat_common.js3
-rw-r--r--addons/mail/static/src/js/mail_thread.js1
-rw-r--r--addons/mail/static/src/xml/mail_chat_common.xml5
-rw-r--r--addons/mail/static/src/xml/mail_thread.xml14
-rw-r--r--addons/mail/wizard/invite.py1
7 files changed, 38 insertions, 13 deletions
diff --git a/addons/mail/models/mail_channel.py b/addons/mail/models/mail_channel.py
index 6eeebcef21d..0ef1c567110 100644
--- a/addons/mail/models/mail_channel.py
+++ b/addons/mail/models/mail_channel.py
@@ -174,7 +174,7 @@ class Channel(models.Model):
self.filtered(lambda channel: channel.channel_type == 'direct_message').mapped('channel_last_seen_partner_ids').write({'is_pinned': True})
# apply shortcode (text only) subsitution
body = self.env['mail.shortcode'].apply_shortcode(body, shortcode_type='text')
- message = super(Channel, self).message_post(body=body, message_type=message_type, subtype=subtype, content_subtype=content_subtype, **kwargs)
+ message = super(Channel, self.with_context(mail_create_nosubscribe=True)).message_post(body=body, subject=subject, message_type=message_type, subtype=subtype, parent_id=parent_id, attachments=attachments, content_subtype=content_subtype, **kwargs)
return message
#------------------------------------------------------
@@ -192,13 +192,22 @@ class Channel(models.Model):
""" Broadcast the current channel header to the given partner ids
:param partner_ids : the partner to notify
"""
+ notifications = self._channel_channel_notifications(partner_ids)
+ self.env['bus.bus'].sendmany(notifications)
+
+ @api.multi
+ def _channel_channel_notifications(self, partner_ids):
+ """ Generate the bus notifications of current channel for the given partner ids
+ :param partner_ids : the partner to send the current channel header
+ :returns list of bus notifications (tuple (bus_channe, message_content))
+ """
notifications = []
for partner in self.env['res.partner'].browse(partner_ids):
user_id = partner.user_ids and partner.user_ids[0] or False
if user_id:
for channel_info in self.sudo(user_id).channel_info():
notifications.append([(self._cr.dbname, 'res.partner', partner.id), channel_info])
- self.env['bus.bus'].sendmany(notifications)
+ return notifications
@api.multi
def _notify(self, message):
@@ -209,8 +218,16 @@ class Channel(models.Model):
:param : mail.message to broadcast
"""
message.ensure_one()
- message_values = message.message_format()[0]
+ notifications = self._channel_message_notifications(message)
+ self.env['bus.bus'].sendmany(notifications)
+ @api.multi
+ def _channel_message_notifications(self, message):
+ """ Generate the bus notifications for the given message
+ :param message : the mail.message to sent
+ :returns list of bus notifications (tuple (bus_channe, message_content))
+ """
+ message_values = message.message_format()[0]
notifications = []
for channel in self:
message_values['channel_ids'] = [channel.id]
@@ -218,7 +235,7 @@ class Channel(models.Model):
# add uuid to allow anonymous to listen
if channel.public == 'public':
notifications.append([channel.uuid, dict(message_values)])
- self.env['bus.bus'].sendmany(notifications)
+ return notifications
@api.multi
def channel_info(self):
@@ -335,7 +352,6 @@ class Channel(models.Model):
session_state.write({
'fold_state': state,
'is_minimized': bool(state != 'closed'),
- 'seen_datetime': time.strftime(DEFAULT_SERVER_DATETIME_FORMAT), # TODO JEM (to check) set seen_datetime to read needaction
})
self.env['bus.bus'].sendone((self._cr.dbname, 'res.partner', self.env.user.partner_id.id), session_state.channel_id.channel_info()[0])
diff --git a/addons/mail/static/src/js/mail_chat_backend.js b/addons/mail/static/src/js/mail_chat_backend.js
index 9353afb68ab..60c18b0282a 100644
--- a/addons/mail/static/src/js/mail_chat_backend.js
+++ b/addons/mail/static/src/js/mail_chat_backend.js
@@ -411,6 +411,7 @@ var ChatMailThread = Widget.extend(mail_thread.MailThreadMixin, ControlPanelMixi
'display_document_link': true,
'display_needaction_button': true,
'emoji_list': this.conv_manager.emoji_list,
+ 'default_username': _t('Anonymous'),
});
this.emoji_set_substitution(this.conv_manager.emoji_list);
// channel business
diff --git a/addons/mail/static/src/js/mail_chat_common.js b/addons/mail/static/src/js/mail_chat_common.js
index a5f52ddf4b1..119c84dd0d7 100644
--- a/addons/mail/static/src/js/mail_chat_common.js
+++ b/addons/mail/static/src/js/mail_chat_common.js
@@ -27,7 +27,7 @@ var ConversationManager = Widget.extend({
this.options = _.clone(options) || {};
_.defaults(this.options, {
placeholder: _t("Say something..."),
- default_username: _t("Visitor"),
+ default_username: _t("Anonymous"),
load_history: true,
focus: false,
});
@@ -171,6 +171,7 @@ var Conversation = Widget.extend({
this._super(parent);
this.options = _.defaults(options || {}, {
'emoji': {},
+ 'default_username': _t('Anonymous'),
'placeholder': _t('Write something ...'),
'loading_history': true,
'focus': true,
diff --git a/addons/mail/static/src/js/mail_thread.js b/addons/mail/static/src/js/mail_thread.js
index 58d63fceda8..99ce20ebf5a 100644
--- a/addons/mail/static/src/js/mail_thread.js
+++ b/addons/mail/static/src/js/mail_thread.js
@@ -552,6 +552,7 @@ var MailThreadMixin = {
'display_needaction_button': false,
'internal_subtypes': [],
'emoji_list': [],
+ 'default_username': _t('Anonymous'),
});
},
start: function(){
diff --git a/addons/mail/static/src/xml/mail_chat_common.xml b/addons/mail/static/src/xml/mail_chat_common.xml
index 745893c11e1..461a6f94d06 100644
--- a/addons/mail/static/src/xml/mail_chat_common.xml
+++ b/addons/mail/static/src/xml/mail_chat_common.xml
@@ -41,9 +41,12 @@
<div class="o_mail_chat_im_message_core">
<!-- author -->
<span class="text-muted">
- <t t-if="message.author_id">
+ <t t-if="message.author_id &amp;&amp; message.author_id[0]">
<strong><t t-esc="message.author_id[1]"/></strong> -
</t>
+ <t t-if="!message.author_id || !message.author_id[0]">
+ <strong><t t-esc="default_username || widget.options.default_username"/></strong> -
+ </t>
<t t-if="!message.author_id">
<strong><t t-esc="message.email_from"/></strong> -
</t>
diff --git a/addons/mail/static/src/xml/mail_thread.xml b/addons/mail/static/src/xml/mail_thread.xml
index 7dee5098b3c..88539e87576 100644
--- a/addons/mail/static/src/xml/mail_thread.xml
+++ b/addons/mail/static/src/xml/mail_thread.xml
@@ -153,14 +153,18 @@
Note by
</t>
<!-- author : partner or email_from -->
- <t t-if="message.author_id">
- <strong class="o_mail_redirect" data-oe-model="res.partner" t-att-data-oe-id="message.author_id[0]"><t t-esc="message.author_id[1]"/></strong> -
+ <t t-if="message.author_id &amp;&amp; message.author_id[1]">
+ <strong class="o_mail_redirect" data-oe-model="res.partner" t-att-data-oe-id="message.author_id[0]"><t t-esc="message.author_id[1]"/></strong>
</t>
- <t t-if="!message.author_id">
- <strong><t t-esc="message.email_from"/></strong> -
+ <t t-if="message.author_id &amp;&amp; !message.author_id[1] &amp;&amp; message.email_from">
+ <strong><t t-esc="message.email_from"/></strong>
</t>
+ <t t-if="message.author_id &amp;&amp; !message.author_id[1] &amp;&amp; !message.email_from">
+ <strong><t t-esc="widget.options.default_username"/></strong>
+ </t>
+
<small t-att-title="moment(message.date, 'YYYY-MM-DD hh:mm:ss').format('LLL')">
- <t t-esc="moment(message.date, 'YYYY-MM-DD hh:mm:ss').format('hh:mm')"/>
+ - <t t-esc="moment(message.date, 'YYYY-MM-DD hh:mm:ss').format('hh:mm')"/>
</small>
<t t-if="message.model &amp;&amp; (message.model != 'mail.channel') &amp;&amp; widget.options.display_document_link">
on <a class="o_mail_redirect" t-att-data-oe-model="message.model" t-att-data-oe-id="message.res_id" href="#"><t t-esc="message.record_name"/></a>
diff --git a/addons/mail/wizard/invite.py b/addons/mail/wizard/invite.py
index ce29f1d600b..8ad772a04cc 100644
--- a/addons/mail/wizard/invite.py
+++ b/addons/mail/wizard/invite.py
@@ -45,7 +45,6 @@ class Invite(models.TransientModel):
model_ids = self.env['ir.model'].search([('model', '=', wizard.res_model)])
model_name = model_ids.name_get()[0][1]
- print "@@@@@", wizard.message
# send an email if option checked and if a message exists (do not send void emails)
if wizard.send_mail and wizard.message and not wizard.message == '<br>': # when deleting the message, cleditor keeps a <br>
# TDE FIXME: use a template + _notification methods