mirror of
https://github.com/OCA/reporting-engine.git
synced 2025-02-16 16:30:38 +02:00
[MIG] report_qweb_signer: Migration to 14.0 updating java's lib for visible signatures
This commit is contained in:
committed by
Enric Tobella
parent
9e635f1c7d
commit
b060acea28
@@ -2,6 +2,10 @@
|
||||
<odoo noupdate="1">
|
||||
<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 -XX:CompressedClassSpaceSize=256m</field>
|
||||
<field name="value">-Xms16M -Xmx16M -XX:CompressedClassSpaceSize=256m</field>
|
||||
</record>
|
||||
<record model="ir.config_parameter" id="report_qweb_signer_java_position_param">
|
||||
<field name="key">report_qweb_signer.java_position_parameters</field>
|
||||
<field name="value">-llx 400 -lly 820 -urx 600 -ury 100 -fs 8</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
||||
@@ -33,14 +33,16 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
</t>
|
||||
</t>
|
||||
</template>
|
||||
<report
|
||||
id="partner_demo_report"
|
||||
model="res.partner"
|
||||
string="Test PDF certificate"
|
||||
report_type="qweb-pdf"
|
||||
name="report_qweb_signer.report_partner_demo"
|
||||
file="report_qweb_signer.report_partner_demo"
|
||||
attachment_use="True"
|
||||
attachment="'test_' + (object.name or '').replace(' ', '_').lower() + '.pdf'"
|
||||
/>
|
||||
<record id="partner_demo_report" model="ir.actions.report">
|
||||
<field name="name">Test PDF certificate</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="report_type">qweb-pdf</field>
|
||||
<field name="report_name">report_qweb_signer.report_partner_demo</field>
|
||||
<field
|
||||
name="attachment"
|
||||
>'test_' + (object.name or '').replace(' ', '_').lower() + '.pdf'</field>
|
||||
<field name="attachment_use">True</field>
|
||||
<field name="binding_model_id" ref="base.model_res_partner" />
|
||||
<field name="binding_type">report</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
||||
@@ -122,8 +122,13 @@ class IrActionsReport(models.Model):
|
||||
irc_param = self.env["ir.config_parameter"].sudo()
|
||||
java_bin = "java -jar"
|
||||
java_param = irc_param.get_param("report_qweb_signer.java_parameters")
|
||||
jar = "{}/../static/jar/jPdfSign.jar".format(me)
|
||||
return "{} {} {} {}".format(java_bin, java_param, jar, opts)
|
||||
java_position_param = irc_param.get_param(
|
||||
"report_qweb_signer.java_position_parameters"
|
||||
)
|
||||
jar = "{}/../static/jar/JSignPdf.jar".format(me)
|
||||
return "{} {} {} {} {}".format(
|
||||
java_bin, java_param, jar, opts, java_position_param
|
||||
)
|
||||
|
||||
def _get_endesive_params(self, certificate):
|
||||
date = datetime.datetime.utcnow() - datetime.timedelta(hours=12)
|
||||
@@ -160,7 +165,7 @@ class IrActionsReport(models.Model):
|
||||
return pdfsigned
|
||||
|
||||
def pdf_sign(self, pdf, certificate):
|
||||
pdfsigned = pdf + ".signed.pdf"
|
||||
pdfsigned = pdf[:-4] + "_signed.pdf"
|
||||
p12 = _normalize_filepath(certificate.path)
|
||||
passwd = _normalize_filepath(certificate.password_file)
|
||||
method_used = certificate.signing_method
|
||||
@@ -169,7 +174,12 @@ class IrActionsReport(models.Model):
|
||||
_("Signing report (PDF): " "Certificate or password file not found")
|
||||
)
|
||||
if method_used == "java":
|
||||
signer_opts = '"{}" "{}" "{}" "{}"'.format(p12, pdf, pdfsigned, passwd)
|
||||
passwd_f = open(passwd, "tr")
|
||||
passwd = passwd_f.read().strip()
|
||||
passwd_f.close()
|
||||
signer_opts = ' "{}" -ksf "{}" -ksp "{}" -V -d "/tmp"'.format(
|
||||
pdf, p12, passwd
|
||||
)
|
||||
signer = self._signer_bin(signer_opts)
|
||||
process = subprocess.Popen(
|
||||
signer, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True
|
||||
@@ -220,7 +230,7 @@ class IrActionsReport(models.Model):
|
||||
for fname in (pdf, signed):
|
||||
try:
|
||||
os.unlink(fname)
|
||||
except (OSError, IOError):
|
||||
except OSError:
|
||||
_logger.error("Error when trying to remove file %s", fname)
|
||||
if certificate.attachment:
|
||||
self._attach_signed_write(res_ids, certificate, content)
|
||||
|
||||
@@ -31,6 +31,7 @@ class ReportCertificate(models.Model):
|
||||
required=True,
|
||||
comodel_name="ir.model",
|
||||
help="Model where apply this certificate",
|
||||
ondelete="cascade",
|
||||
)
|
||||
domain = fields.Char(
|
||||
string="Domain", help="Domain for filtering if sign or not the document",
|
||||
|
||||
@@ -5,3 +5,5 @@
|
||||
* Pedro M. Baeza
|
||||
* Jairo Llopis
|
||||
* David Vidal
|
||||
* Santi Argüeso <santi@comunitea.com>
|
||||
* Omar Castiñeira <omar@comunitea.com>
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
External utilities
|
||||
++++++++++++++++++
|
||||
|
||||
* iText v1.4.8: © 2000-2006, Paulo Soares, Bruno Lowagie and others - License `MPL <http://www.mozilla.org/MPL>`__ or `LGPL2 <http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html>`__ - http://sourceforge.net/projects/itext
|
||||
* jPdfSign: © 2006 Jan Peter Stotz - License `MPL <http://www.mozilla.org/MPL>`__ or `LGPL2 <http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html>`__ (inherited from iText) - http://private.sit.fraunhofer.de/~stotz/software/jpdfsign
|
||||
* Modified jPdfSign: © 2015 Antonio Espinosa - License `MPL <http://www.mozilla.org/MPL>`__ or `LGPL2 <http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html>`__ (inherited from iText) - static/src/java/JPdfSign.java
|
||||
* JSignPdf: © Josef Cacek - License `MPL <http://www.mozilla.org/MPL>`__ or `LGPL2 <http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html>`__ - http://jsignpdf.sourceforge.net/
|
||||
|
||||
Icon
|
||||
++++
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
* When signing multiple documents (if 'Allow only one document' is disable)
|
||||
then 'Save as attachment' is not applied and signed result is not
|
||||
saved as attachment.
|
||||
* To have a visible signature through an image embedded in the resulting PDF.
|
||||
* Add tests.
|
||||
|
||||
BIN
report_qweb_signer/static/jar/JSignPdf.jar
Normal file
BIN
report_qweb_signer/static/jar/JSignPdf.jar
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -2,3 +2,4 @@ py3o.template
|
||||
py3o.formats
|
||||
genshi>=0.7
|
||||
cryptography
|
||||
endesive
|
||||
|
||||
Reference in New Issue
Block a user