[FIX] web: view_form: fixed effective_readonly behavior of the

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
This commit is contained in:
Thibault Delavallée 2014-05-05 16:51:38 +02:00
parent 272b71b2a0
commit 80c77d0355
2 changed files with 6 additions and 2 deletions

View 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));

View File

@ -1336,7 +1336,7 @@
<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>