[FIX] web: view_form: fixed effective_readonly behavior of the
authorThibault Delavallée <tde@openerp.com>
Mon, 5 May 2014 14:51:38 +0000 (16:51 +0200)
committerThibault Delavallée <tde@openerp.com>
Mon, 5 May 2014 14:51:38 +0000 (16:51 +0200)
binary multi files widget. The option to add an attachment should
be available only in edit mode.

lp bug: https://launchpad.net/bugs/1314974 fixed

bzr revid: tde@openerp.com-20140505145138-x9iwzp74ha2q0bp2

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

index 6014e83..d93b59b 100644 (file)
@@ -5408,7 +5408,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);
@@ -5426,6 +5426,9 @@ instance.web.form.FieldMany2ManyBinaryMultiFiles = instance.web.form.AbstractFie
     start: function() {
         this._super(this);
         this.$el.on('change', 'input.oe_form_binary_file', this.on_file_change );
+        this.on("change:effective_readonly", this, function () {
+            this.render_value();
+        });
     },
     set_value: function(value_) {
         value_ = value_ || [];
@@ -5462,6 +5465,7 @@ instance.web.form.FieldMany2ManyBinaryMultiFiles = instance.web.form.AbstractFie
     },
     render_value: function () {
         var self = this;
+        this.$('.oe_add').css('visibility', this.get('effective_readonly') ? 'hidden': '');
         this.read_name_values().then(function (ids) {
             var render = $(instance.web.qweb.render('FieldBinaryFileUploader.files', {'widget': self, 'values': ids}));
             render.on('click', '.oe_delete', _.bind(self.on_file_delete, self));
index 82a3822..bda1a2b 100644 (file)
 <t t-name="FieldBinaryFileUploader">
     <div t-att-style="widget.node.attrs.style" t-attf-class="oe_fileupload #{widget.node.attrs.class ? widget.node.attrs.class :''}">
         <div class="oe_placeholder_files"/>
-        <div class="oe_add" t-if="!widget.get('effective_readonly')">
+        <div class="oe_add">
             <!-- uploader of file -->
             <button class="oe_attach"><span class="oe_e">'</span></button> 
             <span class='oe_attach_label'><t t-esc="widget.string"/></span>