From 2df5ddb06b0bb9f081c0e9b6eb580a0b23efdf8a Mon Sep 17 00:00:00 2001 From: ommo73 Date: Tue, 29 Oct 2019 15:42:23 +0500 Subject: [PATCH] :ambulance: mail_private: fixing errors --- mail_private/models.py | 31 ++++++++++++-------- mail_private/static/src/js/mail_private.js | 11 ++++++- mail_private/static/src/xml/mail_private.xml | 12 ++++++-- 3 files changed, 37 insertions(+), 17 deletions(-) diff --git a/mail_private/models.py b/mail_private/models.py index 58d77e29..319d5d2e 100644 --- a/mail_private/models.py +++ b/mail_private/models.py @@ -67,16 +67,21 @@ def _notify_compute_internal_recipients(self, record, msg_vals): 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) diff --git a/mail_private/static/src/js/mail_private.js b/mail_private/static/src/js/mail_private.js index 26dddec2..82bba9d3 100644 --- a/mail_private/static/src/js/mail_private.js +++ b/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(); diff --git a/mail_private/static/src/xml/mail_private.xml b/mail_private/static/src/xml/mail_private.xml index cb99f9ed..7a3399ec 100644 --- a/mail_private/static/src/xml/mail_private.xml +++ b/mail_private/static/src/xml/mail_private.xml @@ -25,16 +25,22 @@
+
-
+
+ t-att-data-fullname="channel.full_name" + class="custom-control-input" + t-att-id="'o_composer_suggested_channels_p' + count"/> +
-
+