summaryrefslogtreecommitdiff
path: root/addons/mail/static/tests
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/tests
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/tests')
-rw-r--r--addons/mail/static/tests/helpers/mock_server.js63
1 files changed, 61 insertions, 2 deletions
diff --git a/addons/mail/static/tests/helpers/mock_server.js b/addons/mail/static/tests/helpers/mock_server.js
index a58a685040c..28618fcd6cd 100644
--- a/addons/mail/static/tests/helpers/mock_server.js
+++ b/addons/mail/static/tests/helpers/mock_server.js
@@ -105,6 +105,11 @@ MockServer.include({
const context = args.context;
return this._mockRouteMailChatPost(uuid, message_content, context);
}
+ if (route === '/mail/get_suggested_recipients') {
+ const model = args.model;
+ const res_ids = args.res_ids;
+ return this._mockRouteMailGetSuggestedRecipient(model, res_ids);
+ }
if (route === '/mail/init_messaging') {
return this._mockRouteMailInitMessaging();
}
@@ -186,7 +191,8 @@ MockServer.include({
if (args.model === 'mail.channel' && args.method === 'message_post') {
const id = args.args[0];
const kwargs = args.kwargs;
- const context = args.context;
+ const context = kwargs.context;
+ delete kwargs.context;
return this._mockMailChannelMessagePost(id, kwargs, context);
}
if (args.model === 'mail.channel' && args.method === 'notify_typing') {
@@ -252,7 +258,8 @@ MockServer.include({
if (args.method === 'message_post') {
const id = args.args[0];
const kwargs = args.kwargs;
- const context = args.kwargs.context;
+ const context = kwargs.context;
+ delete kwargs.context;
return this._mockMailThreadMessagePost(args.model, [id], kwargs, context);
}
return this._super(route, args);
@@ -312,6 +319,17 @@ MockServer.include({
);
},
/**
+ * Simulates `/mail/get_suggested_recipients` route.
+ *
+ * @private
+ * @returns {string} model
+ * @returns {integer[]} res_ids
+ * @returns {Object}
+ */
+ _mockRouteMailGetSuggestedRecipient(model, res_ids) {
+ return this._mockMailThread_MessageGetSuggestedRecipients(model, res_ids);
+ },
+ /**
* Simulates the `/mail/init_messaging` route.
*
* @private
@@ -1346,6 +1364,47 @@ MockServer.include({
return [author_id, email_from];
},
/**
+ * Simulates `_message_add_suggested_recipient` on `mail.thread`.
+ *
+ * @private
+ * @param {string} model
+ * @param {integer[]} ids
+ * @param {Object} result
+ * @param {Object} [param3={}]
+ * @param {string} [param3.email]
+ * @param {integer} [param3.partner]
+ * @param {string} [param3.reason]
+ * @returns {Object}
+ */
+ _mockMailThread_MessageAddSuggestedRecipient(model, ids, result, { email, partner, reason = '' } = {}) {
+ const record = this._getRecords(model, [['id', 'in', 'ids']])[0];
+ // for simplicity
+ result[record.id].push([partner, email, reason]);
+ return result;
+ },
+ /**
+ * Simulates `_message_get_suggested_recipients` on `mail.thread`.
+ *
+ * @private
+ * @param {string} model
+ * @param {integer[]} ids
+ * @returns {Object}
+ */
+ _mockMailThread_MessageGetSuggestedRecipients(model, ids) {
+ const result = ids.reduce((result, id) => result[id] = [], {});
+ const records = this._getRecords(model, [['id', 'in', ids]]);
+ for (const record in records) {
+ if (record.user_id) {
+ const user = this._getRecords('res.users', [['id', '=', record.user_id]]);
+ if (user.partner_id) {
+ const reason = this.data[model].fields['user_id'].string;
+ this._mockMailThread_MessageAddSuggestedRecipient(result, user.partner_id, reason);
+ }
+ }
+ }
+ return result;
+ },
+ /**
* Simulates `message_post` on `mail.thread`.
*
* @private