[MOD] default max size check has been removed and message dialog change to notification
This commit is contained in:
parent
18cdd307d7
commit
b52dd8051f
|
|
@ -9,7 +9,7 @@ var relational_fields = require('web.relational_fields');
|
|||
var DocumentViewer = require('odx_m2m_attachment_preview.DocumentViewer');
|
||||
var session = require('web.session');
|
||||
var rpc = require('web.rpc');
|
||||
var Dialog = require('web.Dialog');
|
||||
var Notification = require('web.Notification');
|
||||
|
||||
var _t = core._t;
|
||||
var _lt = core._lt;
|
||||
|
|
@ -25,8 +25,12 @@ var FieldMany2ManyAttachmentPreview = AbstractField.extend({
|
|||
template_files: "FieldAttachmentFileUploader.files",
|
||||
supportedFieldTypes: ['many2many'],
|
||||
fieldsToFetch: {
|
||||
name: {type: 'char'},
|
||||
mimetype: {type: 'char'},
|
||||
name: {
|
||||
type: 'char'
|
||||
},
|
||||
mimetype: {
|
||||
type: 'char'
|
||||
},
|
||||
},
|
||||
|
||||
events: {
|
||||
|
|
@ -135,7 +139,9 @@ var FieldMany2ManyAttachmentPreview = AbstractField.extend({
|
|||
ev.stopPropagation();
|
||||
|
||||
var fileID = $(ev.currentTarget).data('id');
|
||||
var record = _.findWhere(this.value.data, {res_id: fileID});
|
||||
var record = _.findWhere(this.value.data, {
|
||||
res_id: fileID
|
||||
});
|
||||
if (record) {
|
||||
this._setValue({
|
||||
operation: 'FORGET',
|
||||
|
|
@ -173,15 +179,15 @@ var FieldMany2ManyAttachmentPreview = AbstractField.extend({
|
|||
});
|
||||
|
||||
// check max file size
|
||||
if (self.fileMaxSize !== 0) {
|
||||
if (file.size > self.fileMaxSize) {
|
||||
file_status = false;
|
||||
Dialog.alert(this, _.str.sprintf(_t('The selected file exceeds the maximum file size of %s MB'),(self.fileMaxSize/1024/1024)), {
|
||||
title: _t("Validation Error"),
|
||||
|
||||
self.displayNotification({
|
||||
type: "danger",
|
||||
message: _.str.sprintf(_t('The selected file exceeds the maximum file size of %s MB'), (self.fileMaxSize / 1024 / 1024))
|
||||
});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (file_status) {
|
||||
if (record) {
|
||||
|
|
@ -225,7 +231,11 @@ var FieldMany2ManyAttachmentPreview = AbstractField.extend({
|
|||
var attachment_ids = this.value.res_ids;
|
||||
_.each(files, function (file) {
|
||||
if (file.error) {
|
||||
self.displayNotification({ title: _t('Uploading Error'), message: file.error, type: 'danger' });
|
||||
self.displayNotification({
|
||||
title: _t('Uploading Error'),
|
||||
message: file.error,
|
||||
type: 'danger'
|
||||
});
|
||||
} else {
|
||||
attachment_ids.push(file.id);
|
||||
self.uploadedFiles[file.id] = true;
|
||||
|
|
@ -247,7 +257,9 @@ var FieldMany2ManyAttachmentPreview = AbstractField.extend({
|
|||
model: 'ir.attachment',
|
||||
method: 'read_as_sudo',
|
||||
kwargs: {
|
||||
domain: [['id', 'in', this.value.res_ids]],
|
||||
domain: [
|
||||
['id', 'in', this.value.res_ids]
|
||||
],
|
||||
fields: ['id', 'mimetype', 'index_content'],
|
||||
},
|
||||
}).then(result => {
|
||||
|
|
@ -269,7 +281,10 @@ var FieldMany2ManyAttachmentPreview = AbstractField.extend({
|
|||
await rpc.query({
|
||||
model: 'res.users',
|
||||
method: 'read',
|
||||
args: [[session.uid], ['set_restriction','max_size']],
|
||||
args: [
|
||||
[session.uid],
|
||||
['set_restriction', 'max_size']
|
||||
],
|
||||
}).then(function (result) {
|
||||
|
||||
if (result[0].set_restriction) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue