From 071e03f1782a7ac6033d2f424275892ef89d2e4c Mon Sep 17 00:00:00 2001 From: Jason Van Malder Date: Fri, 17 Jan 2020 10:50:57 +0000 Subject: [PATCH] [FIX] mail: handle server error in the front-end part Issue - Install Time Off - Marc Demo > Create leave request - Admin > Validate the leave request - Marc Demo > Add an attachment Nothing happens Cause There is a access right issue that is not handled in the JS. Solution Handle it by doing a do_warn. OPW-2171791 closes odoo/odoo#43484 X-original-commit: 6a98c75ebfca694e1e68fa09eca95e47472bed92 Signed-off-by: Jason Van Malder --- addons/mail/i18n/mail.pot | 7 +++++++ addons/mail/static/src/js/attachment_box.js | 8 ++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/addons/mail/i18n/mail.pot b/addons/mail/i18n/mail.pot index 23496dbba76..06feeebb361 100644 --- a/addons/mail/i18n/mail.pot +++ b/addons/mail/i18n/mail.pot @@ -6113,6 +6113,13 @@ msgstr "" msgid "You are in channel #%s." msgstr "" +#. module: mail +#. openerp-web +#: code:addons/mail/static/src/js/attachment_box.js:0 +#, python-format +msgid "You are not allowed to upload an attachment here." +msgstr "" + #. module: mail #. openerp-web #: code:addons/mail/static/src/js/discuss.js:0 diff --git a/addons/mail/static/src/js/attachment_box.js b/addons/mail/static/src/js/attachment_box.js index 17e91b410e9..f0bf5801108 100644 --- a/addons/mail/static/src/js/attachment_box.js +++ b/addons/mail/static/src/js/attachment_box.js @@ -127,8 +127,12 @@ var AttachmentBox = Widget.extend({ /** * @private */ - _onUploaded: function() { - this.trigger_up('reload_attachment_box'); + _onUploaded: function(ev, response) { + if (response.error) { + this.do_warn(_t("Error"), _t("You are not allowed to upload an attachment here.")); + } else { + this.trigger_up('reload_attachment_box'); + } }, });