summaryrefslogtreecommitdiff
path: root/addons/web/static
diff options
context:
space:
mode:
authorTWA <twa@odoo.com>2018-10-18 08:55:07 +0000
committerTWA <twa@odoo.com>2018-10-18 08:55:07 +0000
commit972c8e9ff55177a3a4e381b74acf5abdeca60be5 (patch)
treeb6320f12d23c3fce2d7e7432f5fd280ebae2ca7a /addons/web/static
parent0ac93c38283b0d2f065f8336fd1e2f6a6dedfc19 (diff)
[FIX] web: File upload input on_clear event not propagated
The handler function was used directly in the code. The MouseEvent wasn't provided in that case. This FIX split the handler function and the processing function so that it doesn't interfere. closes odoo/odoo#27929
Diffstat (limited to 'addons/web/static')
-rw-r--r--addons/web/static/src/js/fields/basic_fields.js28
1 files changed, 25 insertions, 3 deletions
diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js
index 12b7b8f302c..00b8874a6b1 100644
--- a/addons/web/static/src/js/fields/basic_fields.js
+++ b/addons/web/static/src/js/fields/basic_fields.js
@@ -1363,7 +1363,7 @@ var AbstractFieldBinary = AbstractField.extend({
'click .o_select_file_button': function () {
this.$('.o_input_file').click();
},
- 'click .o_clear_file_button': 'on_clear',
+ 'click .o_clear_file_button': '_onClearClick',
}),
init: function (parent, name, record) {
this._super.apply(this, arguments);
@@ -1449,11 +1449,33 @@ var AbstractFieldBinary = AbstractField.extend({
});
}
},
- on_clear: function () {
+
+ //--------------------------------------------------------------------------
+ // Private
+ //--------------------------------------------------------------------------
+ /**
+ * Clear the file input
+ *
+ * @private
+ */
+ _clearFile: function (){
this.set_filename('');
this._setValue(false);
this._render();
},
+
+ //--------------------------------------------------------------------------
+ // Handlers
+ //--------------------------------------------------------------------------
+ /**
+ * On "clear file" button click
+ *
+ * @param {MouseEvent} ev
+ * @private
+ */
+ _onClearClick: function (ev) {
+ this._clearFile();
+ },
});
var FieldBinaryImage = AbstractFieldBinary.extend({
@@ -1510,7 +1532,7 @@ var FieldBinaryImage = AbstractFieldBinary.extend({
this.$('> img').remove();
this.$el.prepend($img);
$img.on('error', function () {
- self.on_clear();
+ self._clearFile();
$img.attr('src', self.placeholder);
self.do_warn(_t("Image"), _t("Could not display the selected image."));
});