From 389d040faa13fab528bd9cf0c77f20073e1367c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Theys?= Date: Fri, 28 Oct 2022 11:10:21 +0000 Subject: [PATCH] [IMP] mail: remove obsolete convertData and field from attachment These are no longer used. Part-of: odoo/odoo#104478 --- addons/mail/static/src/models/attachment.js | 43 +-------------------- addons/mail/static/src/models/thread.js | 4 +- 2 files changed, 3 insertions(+), 44 deletions(-) diff --git a/addons/mail/static/src/models/attachment.js b/addons/mail/static/src/models/attachment.js index cd4d9dbd461..4704da5ecc2 100644 --- a/addons/mail/static/src/models/attachment.js +++ b/addons/mail/static/src/models/attachment.js @@ -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(); diff --git a/addons/mail/static/src/models/thread.js b/addons/mail/static/src/models/thread.js index 419b1fd7645..de785d810a1 100644 --- a/addons/mail/static/src/models/thread.js +++ b/addons/mail/static/src/models/thread.js @@ -1123,9 +1123,7 @@ registerModel({ areAttachmentsLoaded: attr({ default: false, }), - attachments: many('Attachment', { - inverse: 'threads', - }), + attachments: many('Attachment'), attachmentsInWebClientView: many('Attachment', { inverse: 'threadsAsAttachmentsInWebClientView', readonly: true,