summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/fields/relational_fields.js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web/static/src/js/fields/relational_fields.js')
-rw-r--r--addons/web/static/src/js/fields/relational_fields.js19
1 files changed, 9 insertions, 10 deletions
diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js
index 1c4c072726b..c4697cdafe1 100644
--- a/addons/web/static/src/js/fields/relational_fields.js
+++ b/addons/web/static/src/js/fields/relational_fields.js
@@ -824,12 +824,9 @@ var FieldX2Many = AbstractField.extend({
return this._super();
}
if (this.renderer) {
- this.renderer.updateState(this.value, {});
this.currentColInvisibleFields = this._evalColumnInvisibleFields();
- this.pager.updateState({
- size: this.value.count,
- columnInvisibleFields: this.currentColInvisibleFields,
- });
+ this.renderer.updateState(this.value, {'columnInvisibleFields': this.currentColInvisibleFields});
+ this.pager.updateState({ size: this.value.count });
return $.when();
}
var arch = this.view.arch;
@@ -839,7 +836,7 @@ var FieldX2Many = AbstractField.extend({
this.currentColInvisibleFields = this._evalColumnInvisibleFields();
this.renderer = new ListRenderer(this, this.value, {
arch: arch,
- mode: this.mode,
+ editable: this.mode === 'edit' && arch.attrs.editable,
addCreateLine: !this.isReadonly && this.activeActions.create,
addTrashIcon: !this.isReadonly && this.activeActions.delete,
viewType: viewType,
@@ -1380,12 +1377,12 @@ var FieldMany2ManyBinaryMultiFiles = AbstractField.extend({
throw _.str.sprintf(msg, this.field.string);
}
+ this.uploadedFiles = {};
this.uploadingFiles = [];
this.fileupload_id = _.uniqueId('oe_fileupload_temp');
$(window).on(this.fileupload_id, this._onFileLoaded.bind(this));
this.metadata = {};
- this._generatedMetadata();
},
destroy: function () {
@@ -1415,10 +1412,10 @@ var FieldMany2ManyBinaryMultiFiles = AbstractField.extend({
_generatedMetadata: function () {
var self = this;
_.each(this.value.data, function (record) {
- // attachments are tagged `allowUnlink` because only new attachments
- // will be unlinked after deletion
+ // tagging `allowUnlink` ascertains if the attachment was user
+ // uploaded or was an existing or system generated attachment
self.metadata[record.id] = {
- allowUnlink: false,
+ allowUnlink: self.uploadedFiles[record.data.id] || false,
url: self._getFileUrl(record.data),
};
});
@@ -1430,6 +1427,7 @@ var FieldMany2ManyBinaryMultiFiles = AbstractField.extend({
_render: function () {
// render the attachments ; as the attachments will changes after each
// _setValue, we put the rendering here to ensure they will be updated
+ this._generatedMetadata();
this.$('.oe_placeholder_files, .oe_attachments')
.replaceWith($(qweb.render('FieldBinaryFileUploader.files', {
widget: this,
@@ -1537,6 +1535,7 @@ var FieldMany2ManyBinaryMultiFiles = AbstractField.extend({
self.do_warn(_t('Uploading Error'), file.error);
} else {
attachment_ids.push(file.id);
+ self.uploadedFiles[file.id] = true;
}
});