[FIX] web: FieldMany2ManyBinaryMultiFiles must extend ReinitializeFieldMixin
authorDenis Ledoux <dle@odoo.com>
Thu, 6 Nov 2014 13:49:25 +0000 (14:49 +0100)
committerDenis Ledoux <dle@odoo.com>
Thu, 6 Nov 2014 13:51:21 +0000 (14:51 +0100)
The add attachment button should be displayed while being in edit mode, but not in view mode
As the widget depends on the form actual mode, the widget should be re-rendered each time the actual mode changes

This is the point of the ReinitializeFieldMixin class

addons/web/static/src/js/view_form.js

index cfada94..077b05c 100644 (file)
@@ -5222,7 +5222,7 @@ instance.web.form.FieldBinaryImage = instance.web.form.FieldBinary.extend({
  * Options on attribute ; "blockui" {Boolean} block the UI or not
  * during the file is uploading
  */
-instance.web.form.FieldMany2ManyBinaryMultiFiles = instance.web.form.AbstractField.extend({
+instance.web.form.FieldMany2ManyBinaryMultiFiles = instance.web.form.AbstractField.extend(instance.web.form.ReinitializeFieldMixin, {
     template: "FieldBinaryFileUploader",
     init: function(field_manager, node) {
         this._super(field_manager, node);
@@ -5236,7 +5236,8 @@ instance.web.form.FieldMany2ManyBinaryMultiFiles = instance.web.form.AbstractFie
         $(window).on(this.fileupload_id, _.bind(this.on_file_loaded, this));
     },
     start: function() {
-        this._super(this);
+        this._super();
+        instance.web.form.ReinitializeFieldMixin.start.call(this);
         this.$el.on('change', 'input.oe_form_binary_file', this.on_file_change );
     },
     set_value: function(value_) {