Browse Source

🚑 mail_private: fixing errors

pull/246/head
ommo73 5 years ago
parent
commit
2df5ddb06b
No known key found for this signature in database GPG Key ID: E7E1F5C23505AFF8
  1. 31
      mail_private/models.py
  2. 11
      mail_private/static/src/js/mail_private.js
  3. 12
      mail_private/static/src/xml/mail_private.xml

31
mail_private/models.py

@ -67,16 +67,21 @@ class MailMessage(models.Model):
recipient_data['channels'] = [i for i in recipient_data['channels'] if i['id'] in cids]
return recipient_data
# First test it without this model
# class MailThread(models.AbstractModel):
# _inherit = 'mail.thread'
#
# @api.multi
# @api.returns('self', lambda value: value.id)
# def message_post(self, body='', subject=None, message_type='notification', subtype=None, parent_id=False,
# attachments=None, content_subtype='html', **kwargs):
# if 'channel_ids' in kwargs:
# kwargs['channel_ids'] = [(4, pid) for pid in kwargs['channel_ids']]
# return super(MailThread, self).message_post(body, subject, message_type,
# subtype, parent_id, attachments,
# content_subtype, **kwargs)
class MailThread(models.AbstractModel):
_inherit = 'mail.thread'
@api.multi
@api.returns('mail.message', lambda value: value.id)
def message_post(self, body='', subject=None,
message_type='notification', subtype=None,
parent_id=False, attachments=None,
notif_layout=False, add_sign=True, model_description=False,
mail_auto_delete=True, **kwargs):
if 'channel_ids' in kwargs:
kwargs['channel_ids'] = [(4, pid) for pid in kwargs['channel_ids']]
return super(MailThread, self).message_post(body, subject,
message_type, subtype,
parent_id, attachments,
notif_layout, add_sign, model_description,
mail_auto_delete, **kwargs)

11
mail_private/static/src/js/mail_private.js

@ -11,11 +11,20 @@ var core = require('web.core');
var Chatter = require('mail.Chatter');
var ChatterComposer = require('mail.composer.Chatter');
var session = require('web.session');
var Thread = require('mail.model.Thread');
var rpc = require('web.rpc');
var config = require('web.config');
var mailUtils = require('mail.utils');
Thread.include({
_postMessage: function (data) {
return this._super.apply(this, arguments).then(function (messageData) {
messageData['channel_ids'] = data['channel_ids'];
return messageData;
});
},
});
Chatter.include({
init: function () {
@ -63,7 +72,7 @@ Chatter.include({
self._composer.on('post_message', self, function (messageData) {
if (options.is_private) {
self._composer.options.isLog = true;
self.composer.options.is_private = options.is_private;
self._composer.options.is_private = options.is_private;
}
self._discardOnReload(messageData).then(function () {
self._disableComposer();

12
mail_private/static/src/xml/mail_private.xml

@ -25,16 +25,22 @@
<t t-jquery="div[class='o_composer_suggested_partners']" t-operation="after">
<div class="o_composer_suggested_channels">
<t t-if="widget.suggested_channels">
<t t-set="count" t-value="0"/>
<t t-foreach='widget.suggested_channels' t-as='channel'>
<div t-attf-title="Add as channel and follower">
<div class="o_checkbox">
<div class="custom-control custom-checkbox">
<input type="checkbox"
t-att-checked="channel.checked ? 'checked' : undefined"
t-att-data-fullname="channel.full_name"/>
t-att-data-fullname="channel.full_name"
class="custom-control-input"
t-att-id="'o_composer_suggested_channels_p' + count"/>
<span/>
</div>
<label class="custom-control-label" t-att-for="'o_composer_suggested_channels_p' + count">
<t t-esc="channel.name"/>
</label>
</div>
</div>
<t t-set="count" t-value="count+1"/>
</t>
</t>
<button class="btn btn-link oe_composer_uncheck" t-if="widget.options.is_private">Uncheck all</button>

Loading…
Cancel
Save