Skip to content

Commit

Permalink
report_qweb_signer addon
Browse files Browse the repository at this point in the history
  • Loading branch information
antespi authored and benwillig committed Apr 17, 2024
1 parent b303901 commit ce7daad
Show file tree
Hide file tree
Showing 21 changed files with 1,069 additions and 0 deletions.
116 changes: 116 additions & 0 deletions report_qweb_signer/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

=======================
Qweb PDF reports signer
=======================

This module extends the functionality of report module to sign
PDFs using a PKCS#12 certificate.


Installation
============

To install this module, you need to install Java JDK::

apt-get install openjdk-7-jre-headless


Configuration
=============

In order to start signing PDF documents you need to configure certificate(s)
to use in your company.

* Go to ``Settings > Companies > Companies > Your company``
* Go to ``Report configuration`` tab
* Click ``Edit``
* Add a new item in ``PDF report certificates`` list
* Click ``Create``
* Set name, certificate file, password file and model
* Optionally you can set a domain and filename pattern for saving as attachment

For example, if you want to sign only customer invoices in open or paid state:

* Model: ``account.invoice``
* Domain: ``[('type','=','out_invoice'), ('state', 'in', ('open', 'paid'))]``
* Save as attachment: ``(object.number or '').replace('/','_') + '.signed.pdf'``

**Note**: Linux user that executes Odoo server process must have
read access to certificate file and password file


Usage
=====

User just prints PDF documents (only Qweb PDF reports supported) as usual,
but signed PDF is automatically downloaded if this document model is configured
as indicated above.

If 'Save as attachment' is configured, signed PDF is saved as attachment and
next time saved one is downloaded without signing again. This is appropiate when
signing date is important, for example, when signing customer invoices.

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/143/8.0

For further information, please visit:

* https://www.odoo.com/forum/help-1


Known issues / Roadmap
======================

* 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.


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
`here <https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_qweb_signer%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.


Credits
=======

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

Icon
----

`Created by Anton Noskov from the Noun Project <https://thenounproject.com/search/?q=signed+contract&i=65694>`_

Contributors
------------

* Rafael Blasco <[email protected]>
* Antonio Espinosa <[email protected]>

Maintainer
----------

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

This module is maintained by the OCA.

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.

To contribute to this module, please visit http://odoo-community.org.
5 changes: 5 additions & 0 deletions report_qweb_signer/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# © 2015 Antiun Ingenieria S.L. - Antonio Espinosa
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import models
31 changes: 31 additions & 0 deletions report_qweb_signer/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
# © 2015 Antiun Ingenieria S.L. - Antonio Espinosa
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": "Qweb PDF reports signer",
"summary": "Sign Qweb PDFs usign a PKCS#12 certificate",
"version": "8.0.1.0.0",
"category": "Reporting",
"website": "http://www.antiun.com",
"author": "Antiun Ingeniería S.L., "
"Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": [
"report",
],
"external_dependencies": {
"bin": ['/usr/bin/java'],
},
"data": [
"security/ir.model.access.csv",
"views/report_certificate_view.xml",
"views/res_company_view.xml",
],
"demo": [
"demo/report_partner.xml",
"demo/report_certificate.xml",
],
}
21 changes: 21 additions & 0 deletions report_qweb_signer/demo/report_certificate.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
© 2015 Antiun Ingenieria S.L. - Antonio Espinosa
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->
<openerp>
<data noupdate="1">

<record id="demo_certificate_test" model="report.certificate">
<field name="company_id" ref="base.main_company"/>
<field name="name">Test OCA certificate</field>
<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">'test_' + (object.name or '').replace(' ', '_').lower() + '.signed.pdf'</field>
</record>

</data>
</openerp>
46 changes: 46 additions & 0 deletions report_qweb_signer/demo/report_partner.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
© 2015 Antiun Ingenieria S.L. - Antonio Espinosa
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->
<openerp>
<data>

<template id="report_partner_demo_document">
<t t-call="report.external_layout">
<div class="page">
<div class="row">
<div class="col-md-12">
This is a sample report for testing PDF certificates
</div>
</div>
<div class="row">
<div class="col-md-12">
<strong>Partner:</strong> <span t-field="o.name"/>
</div>
</div>
</div>
</t>
</template>

<template id="report_partner_demo">
<t t-call="report.html_container">
<t t-foreach="doc_ids" t-as="doc_id">
<t t-raw="translate_doc(doc_id, doc_model, 'lang', 'report_qweb_signer.report_partner_demo_document')"/>
</t>
</t>
</template>

<report
id="partner_demo"
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'"
/>

</data>
</openerp>
161 changes: 161 additions & 0 deletions report_qweb_signer/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * report_qweb_signer
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-11-22 19:28+0000\n"
"PO-Revision-Date: 2015-11-22 19:28+0000\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: report_qweb_signer
#: field:report.certificate,allow_only_one:0
msgid "Allow only one document"
msgstr "Sólo un documento"

#. module: report_qweb_signer
#: field:report.certificate,path:0
msgid "Certificate file path"
msgstr "Ruta al certificado"

#. module: report_qweb_signer
#: view:res.company:report_qweb_signer.view_company_form
msgid "Certificates"
msgstr "Certificados"

#. module: report_qweb_signer
#: model:ir.model,name:report_qweb_signer.model_res_company
msgid "Companies"
msgstr "Compañías"

#. module: report_qweb_signer
#: field:report.certificate,company_id:0
msgid "Company"
msgstr "Compañía"

#. module: report_qweb_signer
#: field:report.certificate,create_uid:0
msgid "Created by"
msgstr "Creado por"

#. module: report_qweb_signer
#: field:report.certificate,create_date:0
msgid "Created on"
msgstr "Creado en"

#. module: report_qweb_signer
#: field:report.certificate,domain:0
msgid "Domain"
msgstr "Dominio"

#. module: report_qweb_signer
#: help:report.certificate,domain:0
msgid "Domain for filtering if sign or not the document"
msgstr "Dominio para filrar si firmar o no el documento"

#. module: report_qweb_signer
#: help:report.certificate,attachment:0
msgid "Filename used to store signed document as attachment. Keep empty to not save signed document."
msgstr "Nombre de fichero usado para guardar el documento firmado como adjunto. Dejar en blanco para no guardar el documento firmado."

#. module: report_qweb_signer
#: field:report.certificate,id:0
msgid "ID"
msgstr "ID"

#. module: report_qweb_signer
#: help:report.certificate,allow_only_one:0
msgid "If True, this certificate can not be used to sign a PDF from several documents."
msgstr "Si está activo, este certificado no puede usarse para firmar un PDF de varios documentos."

#. module: report_qweb_signer
#: field:report.certificate,write_uid:0
msgid "Last Updated by"
msgstr "Última actualización por"

#. module: report_qweb_signer
#: field:report.certificate,write_date:0
msgid "Last Updated on"
msgstr "Última actualización en"

#. module: report_qweb_signer
#: field:report.certificate,model_id:0
msgid "Model"
msgstr "Modelo"

#. module: report_qweb_signer
#: help:report.certificate,model_id:0
msgid "Model where apply this certificate"
msgstr "Modelo en el que usar este certificado para firmar"

#. module: report_qweb_signer
#: field:report.certificate,name:0
msgid "Name"
msgstr "Nombre"

#. module: report_qweb_signer
#: model:ir.actions.act_window,name:report_qweb_signer.action_report_certificate
#: model:ir.ui.menu,name:report_qweb_signer.menu_report_certificate
msgid "PDF certificates"
msgstr "Certificados PDF"

#. module: report_qweb_signer
#: view:report.certificate:report_qweb_signer.view_report_certificate_form
msgid "PDF report certificate"
msgstr "Certificado de informe PDF"

#. module: report_qweb_signer
#: view:report.certificate:report_qweb_signer.view_report_certificate_tree
#: field:res.company,report_certificate_ids:0
msgid "PDF report certificates"
msgstr "Certificados de informes PDF"

#. module: report_qweb_signer
#: field:report.certificate,password_file:0
msgid "Password file path"
msgstr "Ruta al fichero de contraseña"

#. module: report_qweb_signer
#: help:report.certificate,path:0
msgid "Path to PKCS#12 certificate file"
msgstr "Ruta al fichero de certificado PKCS#12"

#. module: report_qweb_signer
#: help:report.certificate,password_file:0
msgid "Path to certificate password file"
msgstr "Ruta al fichero que contiene la contraseña con la que se proteje el fichero de certificado"

#. module: report_qweb_signer
#: code:addons/report_qweb_signer/models/report.py:77
#, python-format
msgid "PortableSigner failed (error code: %s). Message: %s"
msgstr "PortableSigner falló (código de error: %s). Mensaje: %s"

#. module: report_qweb_signer
#: model:ir.model,name:report_qweb_signer.model_report
msgid "Report"
msgstr "Informe"

#. module: report_qweb_signer
#: field:report.certificate,attachment:0
msgid "Save as attachment"
msgstr "Salvar como adjunto"

#. module: report_qweb_signer
#: field:report.certificate,sequence:0
msgid "Sequence"
msgstr "Secuencia"

#. module: report_qweb_signer
#: code:addons/report_qweb_signer/models/report.py:76
#, python-format
msgid "Signing report (PDF)"
msgstr "Firmando informe (PDF)"

7 changes: 7 additions & 0 deletions report_qweb_signer/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-
# © 2015 Antiun Ingenieria S.L. - Antonio Espinosa
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import report
from . import report_certificate
from . import res_company
Loading

0 comments on commit ce7daad

Please sign in to comment.