From 1a26d4135794b50d4b32bb8e5e175e32bf87d0c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Fri, 1 Apr 2022 15:09:44 +0000 Subject: [PATCH] [IMP] mail: introduce AttachmentViewer/print Task-2579306 Part-of: odoo/odoo#88152 --- .../attachment_viewer/attachment_viewer.js | 30 +------------------ .../static/src/models/attachment_viewer.js | 25 ++++++++++++++++ 2 files changed, 26 insertions(+), 29 deletions(-) diff --git a/addons/mail/static/src/components/attachment_viewer/attachment_viewer.js b/addons/mail/static/src/components/attachment_viewer/attachment_viewer.js index f5f02da6990..800b583215f 100644 --- a/addons/mail/static/src/components/attachment_viewer/attachment_viewer.js +++ b/addons/mail/static/src/components/attachment_viewer/attachment_viewer.js @@ -117,34 +117,6 @@ export class AttachmentViewer extends Component { } } - /** - * Prompt the browser print of this attachment. - * - * @private - */ - _print() { - const printWindow = window.open('about:blank', '_new'); - printWindow.document.open(); - printWindow.document.write(` - - - - - - - - `); - printWindow.document.close(); - } - /** * Rotate the image by 90 degrees to the right. * @@ -290,7 +262,7 @@ export class AttachmentViewer extends Component { */ _onClickPrint(ev) { ev.stopPropagation(); - this._print(); + this.attachmentViewer.print(); } /** diff --git a/addons/mail/static/src/models/attachment_viewer.js b/addons/mail/static/src/models/attachment_viewer.js index 0036e77fd8a..990aa45da0b 100644 --- a/addons/mail/static/src/models/attachment_viewer.js +++ b/addons/mail/static/src/models/attachment_viewer.js @@ -112,6 +112,31 @@ registerModel({ } this.dialogOwner.attachmentListOwnerAsAttachmentView.selectPreviousAttachment(); }, + /** + * Prompt the browser print of this attachment. + */ + print() { + const printWindow = window.open('about:blank', '_new'); + printWindow.document.open(); + printWindow.document.write(` + + + + + + + + `); + printWindow.document.close(); + }, /** * @private * @returns {string}