[MIG] report_qweb_signer: Migration to 13.0

[UPD] Update report_qweb_signer.pot

[UPD] README.rst
pull/534/head
Laurent-Corron 2021-06-29 10:16:32 +02:00 committed by Omar (Comunitea)
parent b2b51f0e4c
commit 40dac0db84
10 changed files with 39 additions and 50 deletions

View File

@ -14,13 +14,13 @@ Qweb PDF reports signer
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github
:target: https://github.com/OCA/reporting-engine/tree/12.0/report_qweb_signer
:target: https://github.com/OCA/reporting-engine/tree/13.0/report_qweb_signer
:alt: OCA/reporting-engine
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/reporting-engine-12-0/reporting-engine-12-0-report_qweb_signer
:target: https://translation.odoo-community.org/projects/reporting-engine-13-0/reporting-engine-13-0-report_qweb_signer
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/143/12.0
:target: https://runbot.odoo-community.org/runbot/143/13.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@ -103,7 +103,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/reporting-engine/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_qweb_signer%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_qweb_signer%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
@ -154,6 +154,6 @@ 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/reporting-engine <https://github.com/OCA/reporting-engine/tree/12.0/report_qweb_signer>`_ project on GitHub.
This module is part of the `OCA/reporting-engine <https://github.com/OCA/reporting-engine/tree/13.0/report_qweb_signer>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -6,7 +6,7 @@
{
"name": "Qweb PDF reports signer",
"summary": "Sign Qweb PDFs usign a PKCS#12 certificate",
"version": "12.0.1.0.1",
"version": "13.0.1.0.0",
"category": "Reporting",
"website": "https://github.com/oca/reporting-engine",
"author": "Tecnativa, " "Odoo Community Association (OCA)",
@ -20,8 +20,5 @@
"views/report_certificate_view.xml",
"views/res_company_view.xml",
],
"demo": [
"demo/report_partner_demo.xml",
"demo/report_certificate_demo.xml",
],
"demo": ["demo/report_partner_demo.xml", "demo/report_certificate_demo.xml"],
}

View File

@ -2,6 +2,6 @@
<odoo>
<record model="ir.config_parameter" id="report_qweb_signer_java_param">
<field name="key">report_qweb_signer.java_parameters</field>
<field name="value">-Xms4M -Xmx4M</field>
<field name="value">-Xms4M -Xmx4M -XX:CompressedClassSpaceSize=256m</field>
</record>
</odoo>

View File

@ -11,7 +11,6 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
<field name="path">test.p12</field>
<field name="password_file">test.passwd</field>
<field name="model_id" ref="base.model_res_partner" />
<field name="domain">[('customer', '=', True)]</field>
<field name="allow_only_one" eval="True" />
<field
name="attachment"

View File

@ -1,12 +1,12 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * report_qweb_signer
# * report_qweb_signer
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@ -75,7 +75,9 @@ msgstr ""
#. module: report_qweb_signer
#: model:ir.model.fields,help:report_qweb_signer.field_report_certificate__attachment
msgid "Filename used to store signed document as attachment. Keep empty to not save signed document."
msgid ""
"Filename used to store signed document as attachment. Keep empty to not save"
" signed document."
msgstr ""
#. module: report_qweb_signer
@ -85,7 +87,9 @@ msgstr ""
#. module: report_qweb_signer
#: model:ir.model.fields,help:report_qweb_signer.field_report_certificate__allow_only_one
msgid "If True, this certificate can not be useb to sign a PDF from several documents."
msgid ""
"If True, this certificate can not be useb to sign a PDF from several "
"documents."
msgstr ""
#. module: report_qweb_signer
@ -166,9 +170,11 @@ msgid "Save as attachment"
msgstr ""
#. module: report_qweb_signer
#: code:addons/report_qweb_signer/models/ir_actions_report.py:104
#: code:addons/report_qweb_signer/models/ir_actions_report.py:0
#, python-format
msgid "Saving signed report (PDF): You do not have enough access rights to save attachments"
msgid ""
"Saving signed report (PDF): You do not have enough access rights to save "
"attachments"
msgstr ""
#. module: report_qweb_signer
@ -177,19 +183,20 @@ msgid "Sequence"
msgstr ""
#. module: report_qweb_signer
#: code:addons/report_qweb_signer/models/ir_actions_report.py:122
#: code:addons/report_qweb_signer/models/ir_actions_report.py:0
#, python-format
msgid "Signing report (PDF): Certificate or password file not found"
msgstr ""
#. module: report_qweb_signer
#: code:addons/report_qweb_signer/models/ir_actions_report.py:131
#: code:addons/report_qweb_signer/models/ir_actions_report.py:0
#, python-format
msgid "Signing report (PDF): jPdfSign failed (error code: %s). Message: %s. Output: %s"
msgid ""
"Signing report (PDF): jPdfSign failed (error code: %s). Message: %s. Output:"
" %s"
msgstr ""
#. module: report_qweb_signer
#: model:ir.actions.report,name:report_qweb_signer.partner_demo_report
msgid "Test PDF certificate"
msgstr ""

View File

@ -10,7 +10,7 @@ import tempfile
import time
from contextlib import closing
from odoo import _, api, models
from odoo import _, models
from odoo.exceptions import AccessError, UserError
from odoo.tools.safe_eval import safe_eval
@ -58,9 +58,7 @@ class IrActionsReport(models.Model):
domain = domain + safe_eval(cert.domain)
docs = self.env[cert.model_id.model].search(domain)
if not docs:
_logger.debug(
"Certificate '%s' domain not satisfied", cert.name
)
_logger.debug("Certificate '%s' domain not satisfied", cert.name)
continue
# Certificate match!
return cert
@ -80,14 +78,14 @@ class IrActionsReport(models.Model):
return False
attachment = self.env["ir.attachment"].search(
[
("datas_fname", "=", filename),
("name", "=", filename),
("res_model", "=", certificate.model_id.model),
("res_id", "=", res_ids[0]),
],
limit=1,
)
if attachment:
return base64.decodestring(attachment.datas)
return base64.b64decode(attachment.datas)
return False
def _attach_signed_write(self, res_ids, certificate, signed):
@ -100,8 +98,7 @@ class IrActionsReport(models.Model):
attachment = self.env["ir.attachment"].create(
{
"name": filename,
"datas": base64.encodestring(signed),
"datas_fname": filename,
"datas": base64.b64encode(signed),
"res_model": certificate.model_id.model,
"res_id": res_ids[0],
}
@ -129,10 +126,7 @@ class IrActionsReport(models.Model):
passwd = _normalize_filepath(certificate.password_file)
if not (p12 and passwd):
raise UserError(
_(
"Signing report (PDF): "
"Certificate or password file not found"
)
_("Signing report (PDF): " "Certificate or password file not found")
)
signer_opts = '"{}" "{}" "{}" "{}"'.format(p12, pdf, pdfsigned, passwd)
signer = self._signer_bin(signer_opts)
@ -150,22 +144,18 @@ class IrActionsReport(models.Model):
)
return pdfsigned
@api.multi
def render_qweb_pdf(self, res_ids=None, data=None):
certificate = self._certificate_get(res_ids)
if certificate and certificate.attachment:
signed_content = self._attach_signed_read(res_ids, certificate)
if signed_content:
_logger.debug(
"The signed PDF document '%s/%s' was loaded from the "
"database",
"The signed PDF document '%s/%s' was loaded from the " "database",
self.report_name,
res_ids,
)
return signed_content, "pdf"
content, ext = super(IrActionsReport, self).render_qweb_pdf(
res_ids, data
)
content, ext = super(IrActionsReport, self).render_qweb_pdf(res_ids, data)
if certificate:
# Creating temporary origin PDF
pdf_fd, pdf = tempfile.mkstemp(suffix=".pdf", prefix="report.tmp.")

View File

@ -33,8 +33,7 @@ class ReportCertificate(models.Model):
help="Model where apply this certificate",
)
domain = fields.Char(
string="Domain",
help="Domain for filtering if sign or not the document",
string="Domain", help="Domain for filtering if sign or not the document",
)
allow_only_one = fields.Boolean(
string="Allow only one document",

View File

@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/reporting-engine/tree/12.0/report_qweb_signer"><img alt="OCA/reporting-engine" src="https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/reporting-engine-12-0/reporting-engine-12-0-report_qweb_signer"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/143/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/reporting-engine/tree/13.0/report_qweb_signer"><img alt="OCA/reporting-engine" src="https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/reporting-engine-13-0/reporting-engine-13-0-report_qweb_signer"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/143/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module extends the functionality of report module to sign
PDFs using a PKCS#12 certificate.</p>
<p><strong>Table of contents</strong></p>
@ -459,7 +459,7 @@ saved as attachment.</li>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/reporting-engine/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_qweb_signer%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_qweb_signer%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
@ -508,7 +508,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<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>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/reporting-engine/tree/12.0/report_qweb_signer">OCA/reporting-engine</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/reporting-engine/tree/13.0/report_qweb_signer">OCA/reporting-engine</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>

View File

@ -7,9 +7,7 @@ from odoo.tests.common import HttpCase
class TestReportQwebSigner(HttpCase):
def setUp(self):
super(TestReportQwebSigner, self).setUp()
self.partner = self.env["res.partner"].create(
{"name": "Test partner", "customer": True}
)
self.partner = self.env["res.partner"].create({"name": "Test partner"})
self.report = self.env.ref(
"report_qweb_signer.partner_demo_report"
).with_context(force_report_rendering=True)

View File

@ -55,7 +55,6 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
<record id="action_report_certificate" model="ir.actions.act_window">
<field name="name">PDF certificates</field>
<field name="res_model">report.certificate</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem