diff options
| author | Didier (did) <did@odoo.com> | 2020-09-21 15:44:21 +0000 |
|---|---|---|
| committer | Sébastien Theys <seb@odoo.com> | 2020-09-21 16:49:47 +0000 |
| commit | de1f701e7bd7ebb6f7ebea5c097d980039c4f904 (patch) | |
| tree | d4b931794a6200ebce8809ff73400d65dc391e56 /addons/mail/static/src/models/composer/composer.js | |
| parent | aaec45b9aece17f8c764cd7a89eb243a5fc11924 (diff) | |
[FIX] mail: restore the "to followers" feature
Before this commit, the "to followers" message inside the chatter composer was
missing.
Fix also some padding issue.
This also restore the form dialog when you try to send a message to a suggested
recipient that doesn't have a partner (someone in CC email for eg).
But now, suggested recipient without partner are unchecked by default and the
form open when the user try to check them. If the user discard the form dialog,
the suggested recipient isn't checked.
This is better since only a partner will receive a notification.
task-2280157
closes odoo/odoo#58160
X-original-commit: 67d151cc36871d87b92676357a31a70de5a92fce
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Diffstat (limited to 'addons/mail/static/src/models/composer/composer.js')
| -rw-r--r-- | addons/mail/static/src/models/composer/composer.js | 59 |
1 files changed, 53 insertions, 6 deletions
diff --git a/addons/mail/static/src/models/composer/composer.js b/addons/mail/static/src/models/composer/composer.js index d51f8c37249..230541c77ef 100644 --- a/addons/mail/static/src/models/composer/composer.js +++ b/addons/mail/static/src/models/composer/composer.js @@ -79,6 +79,22 @@ function factory(dependencies) { } /** + * @private + * @returns {mail.partner[]} + */ + _computeRecipients() { + const recipients = [...this.mentionedPartners]; + if (this.thread) { + for (const recipient of this.thread.suggestedRecipientInfoList) { + if (recipient.isSelected) { + recipients.push(recipient.partner); + } + } + } + return [['replace', recipients]]; + } + + /** * Open the full composer modal. */ async openFullComposer() { @@ -89,8 +105,7 @@ function factory(dependencies) { default_body: mailUtils.escapeAndCompactTextContent(this.textInputContent), default_is_log: this.isLog, default_model: this.thread.model, - /* FIXME would need to use suggested_partners here task-2280157 */ - // default_partner_ids: partnerIds, + default_partner_ids: this.recipients.map(partner => partner.id), default_res_id: this.thread.id, mail_post_autofollow: true, }; @@ -135,8 +150,11 @@ function factory(dependencies) { let postData = { attachment_ids: this.attachments.map(attachment => attachment.id), body, - partner_ids: this.mentionedPartners.map(partner => partner.id), + context: { + mail_post_autofollow: true, + }, message_type: 'comment', + partner_ids: this.recipients.map(partner => partner.id), }; if (this.subjectContent) { postData.subject = this.subjectContent; @@ -152,7 +170,7 @@ function factory(dependencies) { model: 'mail.channel', method: command ? 'execute_command' : 'message_post', args: [thread.id], - kwargs: postData + kwargs: postData, })); } else { Object.assign(postData, { @@ -162,12 +180,12 @@ function factory(dependencies) { model: thread.model, method: 'message_post', args: [thread.id], - kwargs: postData + kwargs: postData, })); const [messageData] = await this.async(() => this.env.services.rpc({ model: 'mail.message', method: 'message_format', - args: [[messageId]] + args: [[messageId]], })); this.env.models['mail.message'].insert(Object.assign( {}, @@ -184,6 +202,8 @@ function factory(dependencies) { for (const threadView of this.thread.threadViews) { threadView.addComponentHint('current-partner-just-posted-message', { messageId }); } + thread.refreshFollowers(); + thread.fetchAndUpdateSuggestedRecipients(); this._reset(); } @@ -614,6 +634,33 @@ function factory(dependencies) { dependencies: ['textInputContent'], }), /** + * Determines the extra `mail.partner` (on top of existing followers) + * that will receive the message being composed by `this`, and that will + * also be added as follower of `this.thread`. + */ + recipients: many2many('mail.partner', { + compute: '_computeRecipients', + dependencies: [ + 'mentionedPartners', + 'threadSuggestedRecipientInfoListIsSelected', + // FIXME thread.suggestedRecipientInfoList.partner should be a + // dependency, but it is currently impossible to have a related + // m2o through a m2m. task-2261221 + ] + }), + /** + * Serves as compute dependency. + */ + threadSuggestedRecipientInfoList: many2many('mail.suggested_recipient_info', { + related: 'thread.suggestedRecipientInfoList', + }), + /** + * Serves as compute dependency. + */ + threadSuggestedRecipientInfoListIsSelected: attr({ + related: 'threadSuggestedRecipientInfoList.isSelected', + }), + /** * Composer subject input content. */ subjectContent: attr({ |
