diff --git a/base_report_to_printer_mail/README.rst b/base_report_to_printer_mail/README.rst new file mode 100644 index 00000000000..b4470b103cf --- /dev/null +++ b/base_report_to_printer_mail/README.rst @@ -0,0 +1,83 @@ +================================== +Report to printer - Mail extension +================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:b000c3fd3018962c703b8bdfef05126f83ee6f54f2022a8bed0ed10794426304 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Freport--print--send-lightgray.png?logo=github + :target: https://github.com/OCA/report-print-send/tree/16.0/base_report_to_printer_mail + :alt: OCA/report-print-send +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/report-print-send-16-0/report-print-send-16-0-base_report_to_printer_mail + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/report-print-send&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module disables the print of a report on a selected printer, +when the report has been triggered from a mail template. + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* DynApps NV + +Contributors +~~~~~~~~~~~~ + +* Raf Ven +* Tran Quoc Duong + +Other credits +~~~~~~~~~~~~~ + +The migration of this module from 15.0 to 16.0 was financially supported by Camptocamp + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/report-print-send `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/base_report_to_printer_mail/__init__.py b/base_report_to_printer_mail/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/base_report_to_printer_mail/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/base_report_to_printer_mail/__manifest__.py b/base_report_to_printer_mail/__manifest__.py new file mode 100644 index 00000000000..a8fe63d1a82 --- /dev/null +++ b/base_report_to_printer_mail/__manifest__.py @@ -0,0 +1,14 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Report to printer - Mail extension", + "version": "16.0.1.0.0", + "category": "Generic Modules/Base", + "author": "DynApps NV, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/report-print-send", + "license": "AGPL-3", + "depends": ["mail", "base_report_to_printer"], + "data": [], + "installable": True, + "auto_install": True, +} diff --git a/base_report_to_printer_mail/i18n/base_report_to_printer_mail.pot b/base_report_to_printer_mail/i18n/base_report_to_printer_mail.pot new file mode 100644 index 00000000000..e13311da84c --- /dev/null +++ b/base_report_to_printer_mail/i18n/base_report_to_printer_mail.pot @@ -0,0 +1,34 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_report_to_printer_mail +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: base_report_to_printer_mail +#: model:ir.model.fields,field_description:base_report_to_printer_mail.field_mail_template__display_name +msgid "Display Name" +msgstr "" + +#. module: base_report_to_printer_mail +#: model:ir.model,name:base_report_to_printer_mail.model_mail_template +msgid "Email Templates" +msgstr "" + +#. module: base_report_to_printer_mail +#: model:ir.model.fields,field_description:base_report_to_printer_mail.field_mail_template__id +msgid "ID" +msgstr "" + +#. module: base_report_to_printer_mail +#: model:ir.model.fields,field_description:base_report_to_printer_mail.field_mail_template____last_update +msgid "Last Modified on" +msgstr "" diff --git a/base_report_to_printer_mail/i18n/sv.po b/base_report_to_printer_mail/i18n/sv.po new file mode 100644 index 00000000000..d5434d7ea4d --- /dev/null +++ b/base_report_to_printer_mail/i18n/sv.po @@ -0,0 +1,37 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_report_to_printer_mail +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2022-01-10 14:39+0000\n" +"Last-Translator: Simon S \n" +"Language-Team: none\n" +"Language: sv\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.3.2\n" + +#. module: base_report_to_printer_mail +#: model:ir.model.fields,field_description:base_report_to_printer_mail.field_mail_template__display_name +msgid "Display Name" +msgstr "Visningsnamn" + +#. module: base_report_to_printer_mail +#: model:ir.model,name:base_report_to_printer_mail.model_mail_template +msgid "Email Templates" +msgstr "E-postmallar" + +#. module: base_report_to_printer_mail +#: model:ir.model.fields,field_description:base_report_to_printer_mail.field_mail_template__id +msgid "ID" +msgstr "ID" + +#. module: base_report_to_printer_mail +#: model:ir.model.fields,field_description:base_report_to_printer_mail.field_mail_template____last_update +msgid "Last Modified on" +msgstr "Senast ändrad den" diff --git a/base_report_to_printer_mail/models/__init__.py b/base_report_to_printer_mail/models/__init__.py new file mode 100644 index 00000000000..44e83956ebe --- /dev/null +++ b/base_report_to_printer_mail/models/__init__.py @@ -0,0 +1 @@ +from . import mail_template diff --git a/base_report_to_printer_mail/models/mail_template.py b/base_report_to_printer_mail/models/mail_template.py new file mode 100644 index 00000000000..0a8f13a00c0 --- /dev/null +++ b/base_report_to_printer_mail/models/mail_template.py @@ -0,0 +1,10 @@ +from odoo import models + + +class MailTemplate(models.Model): + _inherit = "mail.template" + + def generate_email(self, res_ids, fields=None): + return super( + MailTemplate, self.with_context(must_skip_send_to_printer=True) + ).generate_email(res_ids, fields=fields) diff --git a/base_report_to_printer_mail/readme/CONTRIBUTORS.rst b/base_report_to_printer_mail/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..0cf0a75c45a --- /dev/null +++ b/base_report_to_printer_mail/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Raf Ven +* Tran Quoc Duong diff --git a/base_report_to_printer_mail/readme/CREDITS.rst b/base_report_to_printer_mail/readme/CREDITS.rst new file mode 100644 index 00000000000..70bc307ad0b --- /dev/null +++ b/base_report_to_printer_mail/readme/CREDITS.rst @@ -0,0 +1 @@ +The migration of this module from 15.0 to 16.0 was financially supported by Camptocamp diff --git a/base_report_to_printer_mail/readme/DESCRIPTION.rst b/base_report_to_printer_mail/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..e4f70c35c7a --- /dev/null +++ b/base_report_to_printer_mail/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This module disables the print of a report on a selected printer, +when the report has been triggered from a mail template. diff --git a/base_report_to_printer_mail/static/description/icon.png b/base_report_to_printer_mail/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/base_report_to_printer_mail/static/description/icon.png differ diff --git a/base_report_to_printer_mail/static/description/index.html b/base_report_to_printer_mail/static/description/index.html new file mode 100644 index 00000000000..376471b5aac --- /dev/null +++ b/base_report_to_printer_mail/static/description/index.html @@ -0,0 +1,428 @@ + + + + + + +Report to printer - Mail extension + + + +
+

Report to printer - Mail extension

+ + +

Beta License: AGPL-3 OCA/report-print-send Translate me on Weblate Try me on Runboat

+

This module disables the print of a report on a selected printer, +when the report has been triggered from a mail template.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • DynApps NV
  • +
+
+
+

Contributors

+ +
+
+

Other credits

+

The migration of this module from 15.0 to 16.0 was financially supported by Camptocamp

+
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/report-print-send project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/base_report_to_printer_mail/tests/__init__.py b/base_report_to_printer_mail/tests/__init__.py new file mode 100644 index 00000000000..fde6ca000a5 --- /dev/null +++ b/base_report_to_printer_mail/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import test_mail diff --git a/base_report_to_printer_mail/tests/test_mail.py b/base_report_to_printer_mail/tests/test_mail.py new file mode 100644 index 00000000000..37b1ea13230 --- /dev/null +++ b/base_report_to_printer_mail/tests/test_mail.py @@ -0,0 +1,104 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from unittest import mock + +from odoo.tests.common import HttpCase + +test_xml_id = "base_report_to_printer.test" + + +class TestMail(HttpCase): + at_install = False + post_install = True + + def setUp(self): + super(TestMail, self).setUp() + self.Model = self.env["ir.model"] + self.report_obj = self.env["ir.actions.report"] + self.partner_obj = self.env["res.partner"] + self.mail_template_obj = self.env["mail.template"] + self.res_partner_model = self.Model.search([("model", "=", "res.partner")]) + self.server = self.env["printing.server"].create({}) + self.report_imd = self.env["ir.model.data"].create( + {"name": "test", "module": "base_report_to_printer", "model": "ir.ui.view"} + ) + self.report_view = self.env["ir.ui.view"].create( + { + "name": "Test", + "type": "qweb", + "xml_id": test_xml_id, + "model_data_id": self.report_imd.id, + "arch": """ +
Test
+
""" + % test_xml_id, + } + ) + self.report_imd.res_id = self.report_view.id + self.report = self.report_obj.create( + { + "name": "Test", + "report_type": "qweb-pdf", + "model": "res.partner", + "report_name": test_xml_id, + } + ) + self.test_partner = self.partner_obj.create( + {"name": "TestingPartner", "city": "OrigCity"} + ) + self.email_template = self.mail_template_obj.create( + { + "name": "TestTemplate", + "email_from": "myself@example.com", + "email_to": "brigitte@example.com", + "partner_to": "%s" % self.test_partner.id, + "model_id": self.res_partner_model.id, + "subject": "About ${object.name}", + "body_html": "

Dear ${object.name}, " + "your parent is ${object.parent_id and " + 'object.parent_id.name or "False"}

', + "report_template": self.report.id, + } + ) + + def new_printer(self): + return self.env["printing.printer"].create( + { + "name": "Printer", + "server_id": self.server.id, + "system_name": "Sys Name", + "default": True, + "status": "unknown", + "status_message": "Msg", + "model": "res.users", + "location": "Location", + "uri": "URI", + } + ) + + def test_generate_email(self): + """ + It should NOT print the report, + regardless of the defined behaviour + """ + self.assertEqual(self.report_view.xml_id, test_xml_id) + self.report.property_printing_action_id.action_type = "server" + self.report.printing_printer_id = self.new_printer() + + with mock.patch( + "odoo.addons.base_report_to_printer.models." + "printing_printer.PrintingPrinter." + "print_document" + ) as print_document: + self.email_template.generate_email( + self.test_partner.id, + fields=[ + "name", + "email_from", + "email_to", + "partner_to", + "subject", + "body_html", + ], + ) + print_document.assert_not_called() diff --git a/setup/base_report_to_printer_mail/odoo/addons/base_report_to_printer_mail b/setup/base_report_to_printer_mail/odoo/addons/base_report_to_printer_mail new file mode 120000 index 00000000000..d46bb682817 --- /dev/null +++ b/setup/base_report_to_printer_mail/odoo/addons/base_report_to_printer_mail @@ -0,0 +1 @@ +../../../../base_report_to_printer_mail \ No newline at end of file diff --git a/setup/base_report_to_printer_mail/setup.py b/setup/base_report_to_printer_mail/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/base_report_to_printer_mail/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)