[IMP] mail: remove obsolete convertData and field from attachment

These are no longer used.

Part-of: odoo/odoo#104478
This commit is contained in:
Sébastien Theys
2022-10-31 12:42:17 +01:00
parent 18dacd13d9
commit 389d040faa
2 changed files with 3 additions and 44 deletions
+2 -41
View File
@@ -2,46 +2,10 @@
import { registerModel } from '@mail/model/model_core';
import { attr, many, one } from '@mail/model/model_field';
import { clear, insert } from '@mail/model/model_field_command';
import { clear } from '@mail/model/model_field_command';
registerModel({
name: 'Attachment',
modelMethods: {
/**
* @static
* @param {Object} data
* @return {Object}
*/
convertData(data) {
const data2 = {};
if ('checksum' in data) {
data2.checksum = data.checksum;
}
if ('filename' in data) {
data2.filename = data.filename;
}
if ('id' in data) {
data2.id = data.id;
}
if ('mimetype' in data) {
data2.mimetype = data.mimetype;
}
if ('name' in data) {
data2.name = data.name;
}
// relation
if ('res_id' in data && 'res_model' in data) {
data2.originThread = insert({
id: data.res_id,
model: data.res_model,
});
}
if ('originThread' in data) {
data2.originThread = data.originThread;
}
return data2;
},
},
recordMethods: {
/**
* Send the attachment for the browser to download.
@@ -126,7 +90,7 @@ registerModel({
return `/web/image/${this.id}?signature=${this.checksum}`;
}
if (this.isPdf) {
const pdf_lib = `/web/static/lib/pdfjs/web/viewer.html?file=`
const pdf_lib = `/web/static/lib/pdfjs/web/viewer.html?file=`;
if (!this.accessToken && this.originThread && this.originThread.model === 'mail.channel') {
return `${pdf_lib}/mail/channel/${this.originThread.id}/attachment/${this.id}`;
}
@@ -309,9 +273,6 @@ registerModel({
inverse: 'originThreadAttachments',
}),
size: attr(),
threads: many('Thread', {
inverse: 'attachments',
}),
threadsAsAttachmentsInWebClientView: many('Thread', {
compute() {
return (this.isPdf || this.isImage) && !this.isUploading ? this.allThreads : clear();
+1 -3
View File
@@ -1123,9 +1123,7 @@ registerModel({
areAttachmentsLoaded: attr({
default: false,
}),
attachments: many('Attachment', {
inverse: 'threads',
}),
attachments: many('Attachment'),
attachmentsInWebClientView: many('Attachment', {
inverse: 'threadsAsAttachmentsInWebClientView',
readonly: true,