summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/models/thread
diff options
context:
space:
mode:
authorDidier (did) <did@odoo.com>2020-09-21 15:44:21 +0000
committerSébastien Theys <seb@odoo.com>2020-09-21 16:49:47 +0000
commitde1f701e7bd7ebb6f7ebea5c097d980039c4f904 (patch)
treed4b931794a6200ebce8809ff73400d65dc391e56 /addons/mail/static/src/models/thread
parentaaec45b9aece17f8c764cd7a89eb243a5fc11924 (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/thread')
-rw-r--r--addons/mail/static/src/models/thread/thread.js56
1 files changed, 56 insertions, 0 deletions
diff --git a/addons/mail/static/src/models/thread/thread.js b/addons/mail/static/src/models/thread/thread.js
index 75a53f67259..6eaed09ad8b 100644
--- a/addons/mail/static/src/models/thread/thread.js
+++ b/addons/mail/static/src/models/thread/thread.js
@@ -5,6 +5,7 @@ const { registerNewModel } = require('mail/static/src/model/model_core.js');
const { attr, many2many, many2one, one2many, one2one } = require('mail/static/src/model/model_field.js');
const throttle = require('mail/static/src/utils/throttle/throttle.js');
const Timer = require('mail/static/src/utils/timer/timer.js');
+const mailUtils = require('mail.utils');
function factory(dependencies) {
@@ -419,6 +420,41 @@ function factory(dependencies) {
}
/**
+ * Performs RPC on the route `/mail/get_suggested_recipients`.
+ *
+ * @static
+ * @param {Object} param0
+ * @param {string} param0.model
+ * @param {integer[]} param0.res_id
+ */
+ static async performRpcMailGetSuggestedRecipients({ model, res_ids }) {
+ const data = await this.env.services.rpc({
+ route: '/mail/get_suggested_recipients',
+ params: {
+ model,
+ res_ids,
+ },
+ });
+ for (const id in data) {
+ const recipientInfoList = data[id].map(recipientInfoData => {
+ const [partner_id, emailInfo, reason] = recipientInfoData;
+ const [name, email] = emailInfo && mailUtils.parseEmail(emailInfo);
+ return {
+ email,
+ name,
+ partner: [partner_id ? ['insert', { id: partner_id }] : ['unlink']],
+ reason,
+ };
+ });
+ this.insert({
+ id: parseInt(id),
+ model,
+ suggestedRecipientInfoList: [['insert-and-replace', recipientInfoList]],
+ });
+ }
+ }
+
+ /**
* @param {string} [stringifiedDomain='[]']
* @returns {mail.thread_cache}
*/
@@ -459,6 +495,19 @@ function factory(dependencies) {
}
/**
+ * Fetches suggested recipients.
+ */
+ async fetchAndUpdateSuggestedRecipients() {
+ if (this.isTemporary) {
+ return;
+ }
+ return this.env.models['mail.thread'].performRpcMailGetSuggestedRecipients({
+ model: this.model,
+ res_ids: [this.id],
+ });
+ }
+
+ /**
* Add current user to provided thread's followers.
*/
async follow() {
@@ -472,6 +521,7 @@ function factory(dependencies) {
},
}));
this.refreshFollowers();
+ this.fetchAndUpdateSuggestedRecipients();
}
/**
@@ -1594,6 +1644,12 @@ function factory(dependencies) {
default: 0,
}),
/**
+ * Determines the `mail.suggested_recipient_info` concerning `this`.
+ */
+ suggestedRecipientInfoList: one2many('mail.suggested_recipient_info', {
+ inverse: 'thread',
+ }),
+ /**
* Members that are currently typing something in the composer of this
* thread, including current partner.
*/