Skip to content
Open
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
90 changes: 90 additions & 0 deletions report_py3o_signer/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
.. 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

==================
Report Py3o Signer
==================

Sign Py3o PDF's using PKCS#12 certificate

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

To install this module, you need to:

#. Do this ...

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

To configure this module, you need to:

#. Go to ...

.. figure:: path/to/local/image.png
:alt: alternative description
:width: 600 px

Usage
=====

To use this module, you need to:

#. Go to ...

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/{repo_id}/{branch}

.. repo_id is available in https://github.com/OCA/maintainer-tools/blob/master/tools/repos_with_ids.txt
.. branch is "8.0" for example

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


Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/{project_repo}/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smash it by providing detailed and welcomed feedback.

Credits
=======

Images
------

* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.

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

* Firstname Lastname <email.address@example.org>
* Second Person <second.person@example.org>

Funders
-------

The development of this module has been financially supported by:

* Company 1 name
* Company 2 name

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 https://odoo-community.org.
1 change: 1 addition & 0 deletions report_py3o_signer/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
15 changes: 15 additions & 0 deletions report_py3o_signer/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2021 Acsone SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Report Py3o Signer",
"summary": """
Sign Py3o PDF's using PKCS#12 certificate""",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "Acsone SA/NV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/reporting-engine",
"depends": ["report_qweb_signer", "report_py3o"],
"data": [],
"demo": [],
}
2 changes: 2 additions & 0 deletions report_py3o_signer/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import ir_actions_report
from . import py3o_report
16 changes: 16 additions & 0 deletions report_py3o_signer/models/ir_actions_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2021 Acsone SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import logging

from odoo import models

_logger = logging.getLogger(__name__)


class IrActionReport(models.Model):
_inherit = "ir.actions.report"

def _is_report_type_signable(self):
res = super()._is_report_type_signable()
return res or (self.report_type == "py3o")
33 changes: 33 additions & 0 deletions report_py3o_signer/models/py3o_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2021 Acsone SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import logging
import os

from odoo import models

_logger = logging.getLogger(__name__)


class Py3oReport(models.TransientModel):
_inherit = "py3o.report"

def _postprocess_report(self, model_instance, result_path):
report = self.ir_actions_report_id
certificate = self.env["ir.actions.report"]._certificate_get(
report, model_instance.ids
)
if not certificate:
return super()._postprocess_report(model_instance, result_path)
_logger.debug(
"Signing PDF document '%s' for ID %s with certificate '%s'",
report.report_name,
model_instance.id,
certificate.name,
)
signed = report.pdf_sign(result_path, certificate)
try:
os.unlink(result_path)
except OSError:
_logger.error("Error when trying to remove file %s", result_path)
return super()._postprocess_report(model_instance, signed)
Binary file added report_py3o_signer/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions setup/report_py3o_signer/odoo/addons/report_py3o_signer
6 changes: 6 additions & 0 deletions setup/report_py3o_signer/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
Loading