Skip to content

Commit 63d358c

Browse files
committed
🚑 mail_private: fixing errors
1 parent 002dcbc commit 63d358c

File tree

3 files changed

+37
-17
lines changed

3 files changed

+37
-17
lines changed

mail_private/models.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,21 @@ def _notify_compute_internal_recipients(self, record, msg_vals):
6767
recipient_data['channels'] = [i for i in recipient_data['channels'] if i['id'] in cids]
6868
return recipient_data
6969

70-
# First test it without this model
71-
# class MailThread(models.AbstractModel):
72-
# _inherit = 'mail.thread'
73-
#
74-
# @api.multi
75-
# @api.returns('self', lambda value: value.id)
76-
# def message_post(self, body='', subject=None, message_type='notification', subtype=None, parent_id=False,
77-
# attachments=None, content_subtype='html', **kwargs):
78-
# if 'channel_ids' in kwargs:
79-
# kwargs['channel_ids'] = [(4, pid) for pid in kwargs['channel_ids']]
80-
# return super(MailThread, self).message_post(body, subject, message_type,
81-
# subtype, parent_id, attachments,
82-
# content_subtype, **kwargs)
70+
71+
class MailThread(models.AbstractModel):
72+
_inherit = 'mail.thread'
73+
74+
@api.multi
75+
@api.returns('mail.message', lambda value: value.id)
76+
def message_post(self, body='', subject=None,
77+
message_type='notification', subtype=None,
78+
parent_id=False, attachments=None,
79+
notif_layout=False, add_sign=True, model_description=False,
80+
mail_auto_delete=True, **kwargs):
81+
if 'channel_ids' in kwargs:
82+
kwargs['channel_ids'] = [(4, pid) for pid in kwargs['channel_ids']]
83+
return super(MailThread, self).message_post(body, subject,
84+
message_type, subtype,
85+
parent_id, attachments,
86+
notif_layout, add_sign, model_description,
87+
mail_auto_delete, **kwargs)

mail_private/static/src/js/mail_private.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,20 @@ var core = require('web.core');
1111
var Chatter = require('mail.Chatter');
1212
var ChatterComposer = require('mail.composer.Chatter');
1313
var session = require('web.session');
14+
var Thread = require('mail.model.Thread');
1415

1516
var rpc = require('web.rpc');
1617
var config = require('web.config');
1718
var mailUtils = require('mail.utils');
1819

20+
Thread.include({
21+
_postMessage: function (data) {
22+
return this._super.apply(this, arguments).then(function (messageData) {
23+
messageData['channel_ids'] = data['channel_ids'];
24+
return messageData;
25+
});
26+
},
27+
});
1928

2029
Chatter.include({
2130
init: function () {
@@ -63,7 +72,7 @@ Chatter.include({
6372
self._composer.on('post_message', self, function (messageData) {
6473
if (options.is_private) {
6574
self._composer.options.isLog = true;
66-
self.composer.options.is_private = options.is_private;
75+
self._composer.options.is_private = options.is_private;
6776
}
6877
self._discardOnReload(messageData).then(function () {
6978
self._disableComposer();

mail_private/static/src/xml/mail_private.xml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,22 @@
2525
<t t-jquery="div[class='o_composer_suggested_partners']" t-operation="after">
2626
<div class="o_composer_suggested_channels">
2727
<t t-if="widget.suggested_channels">
28+
<t t-set="count" t-value="0"/>
2829
<t t-foreach='widget.suggested_channels' t-as='channel'>
2930
<div t-attf-title="Add as channel and follower">
30-
<div class="o_checkbox">
31+
<div class="custom-control custom-checkbox">
3132
<input type="checkbox"
3233
t-att-checked="channel.checked ? 'checked' : undefined"
33-
t-att-data-fullname="channel.full_name"/>
34+
t-att-data-fullname="channel.full_name"
35+
class="custom-control-input"
36+
t-att-id="'o_composer_suggested_channels_p' + count"/>
3437
<span/>
38+
<label class="custom-control-label" t-att-for="'o_composer_suggested_channels_p' + count">
39+
<t t-esc="channel.name"/>
40+
</label>
3541
</div>
36-
<t t-esc="channel.name"/>
3742
</div>
43+
<t t-set="count" t-value="count+1"/>
3844
</t>
3945
</t>
4046
<button class="btn btn-link oe_composer_uncheck" t-if="widget.options.is_private">Uncheck all</button>

0 commit comments

Comments
 (0)