diff options
| author | Sébastien Theys <seb@odoo.com> | 2020-08-27 15:07:50 +0000 |
|---|---|---|
| committer | Alexandre Kühn <aku@odoo.com> | 2020-08-27 16:51:50 +0000 |
| commit | c690f63de88b74bf6576fa83adcba3d57bcb1a74 (patch) | |
| tree | 7c9e23cb73bd96c14e73b98992b65f155bae8e1e /addons/mail/static/src/models | |
| parent | ae9a6aa200b5a66d5da1dc166f99261bc5ad06d0 (diff) | |
[FIX] mail: prevent "record created" from being twice in the chatter
task-2280184
closes odoo/odoo#56691
X-original-commit: 1af2cc1b2190623739085de83870fb415cbdccf1
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Diffstat (limited to 'addons/mail/static/src/models')
| -rw-r--r-- | addons/mail/static/src/models/message/message.js | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/addons/mail/static/src/models/message/message.js b/addons/mail/static/src/models/message/message.js index e982df36667..c92714fb3e8 100644 --- a/addons/mail/static/src/models/message/message.js +++ b/addons/mail/static/src/models/message/message.js @@ -4,7 +4,7 @@ odoo.define('mail/static/src/models/message/message.js', function (require) { const emojis = require('mail.emojis'); const { registerNewModel } = require('mail/static/src/model/model_core.js'); const { attr, many2many, many2one, one2many } = require('mail/static/src/model/model_field.js'); -const { addLink, parseAndTransform } = require('mail.utils'); +const { addLink, htmlToTextContentInline, parseAndTransform } = require('mail.utils'); const { str_to_datetime } = require('web.time'); @@ -353,6 +353,18 @@ function factory(dependencies) { * @private * @returns {boolean} */ + _computeIsBodyEqualSubtypeDescription() { + if (!this.body || !this.subtype_description) { + return false; + } + const inlineBody = htmlToTextContentInline(this.body); + return inlineBody.toLowerCase() === this.subtype_description.toLowerCase(); + } + + /** + * @private + * @returns {boolean} + */ _computeIsModeratedByCurrentPartner() { return ( this.moderation_status === 'pending_moderation' && @@ -480,6 +492,34 @@ function factory(dependencies) { 'messagingCurrentPartner', ], }), + /** + * States whether `body` and `subtype_description` contain similar + * values. + * + * This is necessary to avoid displaying both of them together when they + * contain duplicate information. This will especially happen with + * messages that are posted automatically at the creation of a record + * (messages that serve as tracking messages). They do have hard-coded + * "record created" body while being assigned a subtype with a + * description that states the same information. + * + * Fixing newer messages is possible by not assigning them a duplicate + * body content, but the check here is still necessary to handle + * existing messages. + * + * Limitations: + * - A translated subtype description might not match a non-translatable + * body created by a user with a different language. + * - Their content might be mostly but not exactly the same. + */ + isBodyEqualSubtypeDescription: attr({ + compute: '_computeIsBodyEqualSubtypeDescription', + default: false, + dependencies: [ + 'body', + 'subtype_description', + ], + }), isModeratedByCurrentPartner: attr({ compute: '_computeIsModeratedByCurrentPartner', default: false, |
