Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[15.0][FIX] base_report_to_printer: Report send to printer when is rendered from email template #373

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions base_report_to_printer/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ Contributors
* Matias Peralta <mnp@adhoc.com.ar>
* Akim Juillerat <akim.juillerat@camptocamp.com>

* `Tecnativa <https://www.tecnativa.com>`_

* Sergio Teruel
* David Vidal

Maintainers
~~~~~~~~~~~

Expand Down
2 changes: 1 addition & 1 deletion base_report_to_printer/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
" Open for Small Business Ltd",
"website": "https://github.com/OCA/report-print-send",
"license": "AGPL-3",
"depends": ["web"],
"depends": ["mail"],
"data": [
"data/printing_data.xml",
"security/security.xml",
Expand Down
1 change: 1 addition & 0 deletions base_report_to_printer/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from . import ir_actions_report
from . import mail_template
from . import printing_action
from . import printing_job
from . import printing_printer
Expand Down
19 changes: 19 additions & 0 deletions base_report_to_printer/models/mail_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2024 Tecnativa - Sergio Teruel
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import models


class MailTemplate(models.Model):
_inherit = "mail.template"

def generate_email(self, res_ids, fields):
"""Ensure that any report rendered to send it by email not is sent to printer
directly if the report is setting to send it to printer.
For example, user set delivery slip report redirect to printer and
'Send an email when picking is validated' is active, if we do not inject this
context the report will be send twice to printer.
"""
return super(

Check warning on line 17 in base_report_to_printer/models/mail_template.py

View check run for this annotation

Codecov / codecov/patch

base_report_to_printer/models/mail_template.py#L17

Added line #L17 was not covered by tests
MailTemplate, self.with_context(must_skip_send_to_printer=True)
).generate_email(res_ids, fields)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this solution is already covered in a module that is not migrated.
https://github.com/OCA/report-print-send/blob/14.0/base_report_to_printer_mail/models/mail_template.py

I don't know if it is convenient to keep it separate and migrate the other module.

5 changes: 5 additions & 0 deletions base_report_to_printer/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@
* Alexandre Fayolle <alexandre.fayolle@camptocamp.com>
* Matias Peralta <mnp@adhoc.com.ar>
* Akim Juillerat <akim.juillerat@camptocamp.com>

* `Tecnativa <https://www.tecnativa.com>`_

* Sergio Teruel
* David Vidal
16 changes: 9 additions & 7 deletions base_report_to_printer/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@

/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.

See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -275,7 +274,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: gray; } /* line numbers */
pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -301,7 +300,7 @@
span.pre {
white-space: pre }

span.problematic, pre.problematic {
span.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -510,14 +509,17 @@ <h2><a class="toc-backref" href="#toc-entry-10">Contributors</a></h2>
<li>Alexandre Fayolle &lt;<a class="reference external" href="mailto:alexandre.fayolle&#64;camptocamp.com">alexandre.fayolle&#64;camptocamp.com</a>&gt;</li>
<li>Matias Peralta &lt;<a class="reference external" href="mailto:mnp&#64;adhoc.com.ar">mnp&#64;adhoc.com.ar</a>&gt;</li>
<li>Akim Juillerat &lt;<a class="reference external" href="mailto:akim.juillerat&#64;camptocamp.com">akim.juillerat&#64;camptocamp.com</a>&gt;</li>
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a><ul>
<li>Sergio Teruel</li>
<li>David Vidal</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-11">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>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.</p>
Expand Down
Loading