[FIX] Solve Internal error during Upload/Add image in form view
This commit is contained in:
parent
32d5a77281
commit
31f5af381e
@ -16,10 +16,10 @@ var FormRenderer = BasicRenderer.extend({
|
|||||||
events: _.extend({}, BasicRenderer.prototype.events, {
|
events: _.extend({}, BasicRenderer.prototype.events, {
|
||||||
'click .o_notification_box .oe_field_translate': '_onTranslate',
|
'click .o_notification_box .oe_field_translate': '_onTranslate',
|
||||||
'click .oe_title, .o_inner_group': '_onClick',
|
'click .oe_title, .o_inner_group': '_onClick',
|
||||||
'change .o_input_file': '_onChangeInputFile',
|
'change #multi_attachment .o_input_file': '_onChangeInputFile',
|
||||||
'dragover .o_form_sheet_bg': '_onDragEnterForm',
|
'dragover .o_form_sheet_bg': '_onDragEnterForm',
|
||||||
'dragleave .o_input_file': '_onDragLeaveForm',
|
'dragleave #multi_attachment .o_input_file': '_onDragLeaveForm',
|
||||||
'drop .o_input_file': '_onDropFile',
|
'drop #multi_attachment .o_input_file': '_onDropFile',
|
||||||
}),
|
}),
|
||||||
/**
|
/**
|
||||||
* @override
|
* @override
|
||||||
@ -27,7 +27,8 @@ var FormRenderer = BasicRenderer.extend({
|
|||||||
init: function (parent, state, params) {
|
init: function (parent, state, params) {
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
this.idsForLabels = {};
|
this.idsForLabels = {};
|
||||||
if (this.activeActions && this.activeActions.edit) {
|
this.is_editable = params.editable;
|
||||||
|
if (this.is_editable) {
|
||||||
this.fileuploadId = _.uniqueId('oe_fileupload');
|
this.fileuploadId = _.uniqueId('oe_fileupload');
|
||||||
$(window).on(this.fileuploadId, this._onFileUploaded.bind(this));
|
$(window).on(this.fileuploadId, this._onFileUploaded.bind(this));
|
||||||
}
|
}
|
||||||
@ -850,38 +851,38 @@ var FormRenderer = BasicRenderer.extend({
|
|||||||
});
|
});
|
||||||
this.$el.find('.o_notebook ul.nav-tabs').tabCollapse();
|
this.$el.find('.o_notebook ul.nav-tabs').tabCollapse();
|
||||||
// for Drag and Drop Attachment(s)
|
// for Drag and Drop Attachment(s)
|
||||||
if (this.activeActions.edit) {
|
if (this.is_editable) {
|
||||||
this.$attach_form = $(qweb.render('DragAndDropAttachment', {widget: this}));
|
this.$attach_form = $(qweb.render('DragAndDropAttachment', {widget: this}));
|
||||||
this.$el.find('.o_form_sheet_bg').prepend(this.$attach_form);
|
this.$el.find('.o_form_sheet_bg').prepend(this.$attach_form);
|
||||||
this.$el.find('.o_form_sheet_bg .o_input_file').addClass('hide');
|
this.$el.find('.o_form_sheet_bg #multi_attachment .o_input_file').addClass('hide');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_onChangeInputFile: function (event) {
|
_onChangeInputFile: function (event) {
|
||||||
if (!this.activeActions.edit) return;
|
if (!this.is_editable) return;
|
||||||
var $event = $(event.target);
|
var $event = $(event.target);
|
||||||
if ($event.val() !== '') {
|
if ($event.val() !== '') {
|
||||||
var $binaryForm = this.$el.find('.o_form_sheet_bg form.o_form_binary_form');
|
var $binaryForm = this.$el.find('.o_form_sheet_bg #multi_attachment form.o_form_binary_form');
|
||||||
$binaryForm.submit();
|
$binaryForm.submit();
|
||||||
framework.blockUI();
|
framework.blockUI();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_onDragEnterForm: function (e) {
|
_onDragEnterForm: function (e) {
|
||||||
if (!this.activeActions.edit) return;
|
if (!this.is_editable) return;
|
||||||
var $input = this.$el.find('.o_form_sheet_bg .o_input_file');
|
var $input = this.$el.find('.o_form_sheet_bg #multi_attachment .o_input_file');
|
||||||
$input.removeClass('hide').addClass('f_attachment_input');
|
$input.removeClass('hide').addClass('f_attachment_input');
|
||||||
$input.parent().parent().addClass('f_attachment')
|
$input.parent().parent().addClass('f_attachment')
|
||||||
},
|
},
|
||||||
_onDragLeaveForm: function (e) {
|
_onDragLeaveForm: function (e) {
|
||||||
if (!this.activeActions.edit) return;
|
if (!this.is_editable) return;
|
||||||
var $input = this.$el.find('.o_form_sheet_bg .o_input_file');
|
var $input = this.$el.find('.o_form_sheet_bg #multi_attachment .o_input_file');
|
||||||
$input.addClass('hide').removeClass('f_attachment_input');
|
$input.addClass('hide').removeClass('f_attachment_input');
|
||||||
$input.parent().parent().removeClass('f_attachment')
|
$input.parent().parent().removeClass('f_attachment')
|
||||||
},
|
},
|
||||||
_onDropFile: function (event) {
|
_onDropFile: function (event) {
|
||||||
if (!this.activeActions.edit) return;
|
if (!this.is_editable) return;
|
||||||
var $event = $(event.target);
|
var $event = $(event.target);
|
||||||
if ($event.val() !== '') {
|
if ($event.val() !== '') {
|
||||||
var $binaryForm = this.$el.find('.o_form_sheet_bg form.o_form_binary_form');
|
var $binaryForm = this.$el.find('.o_form_sheet_bg #multi_attachment form.o_form_binary_form');
|
||||||
$binaryForm.submit();
|
$binaryForm.submit();
|
||||||
framework.blockUI();
|
framework.blockUI();
|
||||||
}
|
}
|
||||||
@ -898,7 +899,7 @@ var FormRenderer = BasicRenderer.extend({
|
|||||||
framework.unblockUI();
|
framework.unblockUI();
|
||||||
this._getAttachments().then(function (attachments) {
|
this._getAttachments().then(function (attachments) {
|
||||||
self.trigger_up('update_sidebar_attachments', {files: attachments});
|
self.trigger_up('update_sidebar_attachments', {files: attachments});
|
||||||
var $input = self.$el.find('.o_form_sheet_bg .o_input_file');
|
var $input = self.$el.find('.o_form_sheet_bg #multi_attachment .o_input_file');
|
||||||
$input.addClass('hide').removeClass('f_attachment_input');
|
$input.addClass('hide').removeClass('f_attachment_input');
|
||||||
$input.parent().parent().removeClass('f_attachment')
|
$input.parent().parent().removeClass('f_attachment')
|
||||||
});
|
});
|
||||||
|
@ -40,6 +40,8 @@ var FormView = BasicView.extend({
|
|||||||
this.controllerParams.mode = mode;
|
this.controllerParams.mode = mode;
|
||||||
|
|
||||||
this.rendererParams.mode = mode;
|
this.rendererParams.mode = mode;
|
||||||
|
|
||||||
|
this.rendererParams.editable = this.controllerParams.activeActions.edit;
|
||||||
},
|
},
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
|
@ -37,12 +37,14 @@
|
|||||||
</t>
|
</t>
|
||||||
|
|
||||||
<t t-name="DragAndDropAttachment">
|
<t t-name="DragAndDropAttachment">
|
||||||
<t t-call="HiddenInputFile">
|
<div id="multi_attachment">
|
||||||
<t t-set="fileupload_id" t-value="widget.fileuploadId"/>
|
<t t-call="HiddenInputFile">
|
||||||
<t t-set="fileupload_action" t-translation="off">/web/binary/upload_attachment</t>
|
<t t-set="fileupload_id" t-value="widget.fileuploadId"/>
|
||||||
<t t-set="multi_upload" t-value="true"/>
|
<t t-set="fileupload_action" t-translation="off">/web/binary/upload_attachment</t>
|
||||||
<input type="hidden" name="model" t-att-value="widget.state.model"/>
|
<t t-set="multi_upload" t-value="true"/>
|
||||||
<input type="hidden" name="id" t-att-value="widget.state.res_id"/>
|
<input type="hidden" name="model" t-att-value="widget.state.model"/>
|
||||||
</t>
|
<input type="hidden" name="id" t-att-value="widget.state.res_id"/>
|
||||||
|
</t>
|
||||||
|
</div>
|
||||||
</t>
|
</t>
|
||||||
</templates>
|
</templates>
|
||||||
|
Loading…
Reference in New Issue
Block a user