summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/models
diff options
context:
space:
mode:
authorXavier Dubuc <xdu@odoo.com>2020-08-18 12:24:10 +0000
committerAlexandre Kühn <aku@odoo.com>2020-08-21 12:57:44 +0000
commit0263acee7f355e7367686a461c21f28ea34cfa9a (patch)
tree5f445f8b559c46263d438442b505f629d9545015 /addons/mail/static/src/models
parentf25b730b2f548616d62cf8f30907103116e8c0fd (diff)
[FIX] mail: prevent composer to send message if pending uploads
task-2317862 closes odoo/odoo#56303 X-original-commit: 3b5cd048f1dfa18869e95b173b4232b4bb189025 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Diffstat (limited to 'addons/mail/static/src/models')
-rw-r--r--addons/mail/static/src/models/composer/composer.js35
1 files changed, 34 insertions, 1 deletions
diff --git a/addons/mail/static/src/models/composer/composer.js b/addons/mail/static/src/models/composer/composer.js
index f2d376fd14b..421ca3061d2 100644
--- a/addons/mail/static/src/models/composer/composer.js
+++ b/addons/mail/static/src/models/composer/composer.js
@@ -294,7 +294,10 @@ function factory(dependencies) {
* @returns {boolean}
*/
_computeCanPostMessage() {
- return this.textInputContent || this.attachments.length !== 0;
+ if (!this.textInputContent && this.attachments.length === 0) {
+ return false;
+ }
+ return !this.hasUploadingAttachment;
}
/**
@@ -320,6 +323,14 @@ function factory(dependencies) {
}
/**
+ * @private
+ * @returns {boolean}
+ */
+ _computeHasUploadingAttachment() {
+ return this.attachments.some(attachment => attachment.isTemporary);
+ }
+
+ /**
* Detects if mentioned partners are still in the composer text input content
* and removes them if not.
*
@@ -540,10 +551,21 @@ function factory(dependencies) {
attachments: many2many('mail.attachment', {
inverse: 'composers',
}),
+ /**
+ * This field watches the uploading (= temporary) status of attachments
+ * linked to this composer.
+ *
+ * Useful to determine whether there are some attachments that are being
+ * uploaded.
+ */
+ attachmentsAreTemporary: attr({
+ related: 'attachments.isTemporary',
+ }),
canPostMessage: attr({
compute: '_computeCanPostMessage',
dependencies: [
'attachments',
+ 'hasUploadingAttachment',
'textInputContent',
],
default: false,
@@ -563,6 +585,17 @@ function factory(dependencies) {
'mainSuggestedPartners',
],
}),
+ /**
+ * This field determines whether some attachments linked to this
+ * composer are being uploaded.
+ */
+ hasUploadingAttachment: attr({
+ compute: '_computeHasUploadingAttachment',
+ dependencies: [
+ 'attachments',
+ 'attachmentsAreTemporary',
+ ],
+ }),
hasFocus: attr({
default: false,
}),