From 40dac0db847308577d46939b9407b2ec8900f6d8 Mon Sep 17 00:00:00 2001
From: Laurent-Corron
Date: Tue, 29 Jun 2021 10:16:32 +0200
Subject: [PATCH] [MIG] report_qweb_signer: Migration to 13.0
[UPD] Update report_qweb_signer.pot
[UPD] README.rst
---
report_qweb_signer/README.rst | 10 +++----
report_qweb_signer/__manifest__.py | 7 ++---
report_qweb_signer/data/defaults.xml | 2 +-
.../demo/report_certificate_demo.xml | 1 -
.../i18n/report_qweb_signer.pot | 29 ++++++++++++-------
.../models/ir_actions_report.py | 26 +++++------------
.../models/report_certificate.py | 3 +-
.../static/description/index.html | 6 ++--
.../tests/test_report_qweb_signer.py | 4 +--
.../views/report_certificate_view.xml | 1 -
10 files changed, 39 insertions(+), 50 deletions(-)
diff --git a/report_qweb_signer/README.rst b/report_qweb_signer/README.rst
index f4b42891e..083e15321 100644
--- a/report_qweb_signer/README.rst
+++ b/report_qweb_signer/README.rst
@@ -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 `_.
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 `_.
+`feedback `_.
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 `_ project on GitHub.
+This module is part of the `OCA/reporting-engine `_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/report_qweb_signer/__manifest__.py b/report_qweb_signer/__manifest__.py
index 90a587090..ce2ad41b1 100644
--- a/report_qweb_signer/__manifest__.py
+++ b/report_qweb_signer/__manifest__.py
@@ -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"],
}
diff --git a/report_qweb_signer/data/defaults.xml b/report_qweb_signer/data/defaults.xml
index f343c1307..d08649a1b 100644
--- a/report_qweb_signer/data/defaults.xml
+++ b/report_qweb_signer/data/defaults.xml
@@ -2,6 +2,6 @@
report_qweb_signer.java_parameters
- -Xms4M -Xmx4M
+ -Xms4M -Xmx4M -XX:CompressedClassSpaceSize=256m
diff --git a/report_qweb_signer/demo/report_certificate_demo.xml b/report_qweb_signer/demo/report_certificate_demo.xml
index 10ea25c26..65542ecfb 100644
--- a/report_qweb_signer/demo/report_certificate_demo.xml
+++ b/report_qweb_signer/demo/report_certificate_demo.xml
@@ -11,7 +11,6 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
test.p12
test.passwd
- [('customer', '=', True)]
\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 ""
-
diff --git a/report_qweb_signer/models/ir_actions_report.py b/report_qweb_signer/models/ir_actions_report.py
index 81c8aa4e0..771ae0f04 100644
--- a/report_qweb_signer/models/ir_actions_report.py
+++ b/report_qweb_signer/models/ir_actions_report.py
@@ -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.")
diff --git a/report_qweb_signer/models/report_certificate.py b/report_qweb_signer/models/report_certificate.py
index eb20abde4..7384b2aac 100644
--- a/report_qweb_signer/models/report_certificate.py
+++ b/report_qweb_signer/models/report_certificate.py
@@ -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",
diff --git a/report_qweb_signer/static/description/index.html b/report_qweb_signer/static/description/index.html
index 3f12c6e43..44fd2f955 100644
--- a/report_qweb_signer/static/description/index.html
+++ b/report_qweb_signer/static/description/index.html
@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-

+

This module extends the functionality of report module to sign
PDFs using a PKCS#12 certificate.
Table of contents
@@ -459,7 +459,7 @@ saved as attachment.
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 smashing it by providing a detailed and welcomed
-feedback.
+feedback.
Do not contact contributors directly about support or help with technical issues.
@@ -508,7 +508,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
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 project on GitHub.
+
This module is part of the OCA/reporting-engine project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/report_qweb_signer/tests/test_report_qweb_signer.py b/report_qweb_signer/tests/test_report_qweb_signer.py
index 8aff4e068..d39341784 100644
--- a/report_qweb_signer/tests/test_report_qweb_signer.py
+++ b/report_qweb_signer/tests/test_report_qweb_signer.py
@@ -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)
diff --git a/report_qweb_signer/views/report_certificate_view.xml b/report_qweb_signer/views/report_certificate_view.xml
index 2857ef4e6..1d06e4383 100644
--- a/report_qweb_signer/views/report_certificate_view.xml
+++ b/report_qweb_signer/views/report_certificate_view.xml
@@ -55,7 +55,6 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
PDF certificates
report.certificate
- form
tree,form