Merge pull request #615 from tegin/13.0-gh

Updated from template
pull/621/head
Enric Tobella 2022-04-21 23:44:08 +02:00 committed by GitHub
commit 151d176331
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 131 additions and 75 deletions

View File

@ -1,7 +1,7 @@
# Do NOT update manually; changes here will be overwritten by Copier
_commit: v1.6.1
_src_path: git+https://github.com/OCA/oca-addons-repo-template
ci: Travis
ci: GitHub
dependency_installation_mode: PIP
generate_requirements_txt: true
include_wkhtmltopdf: true

69
.github/workflows/test.yml vendored 100644
View File

@ -0,0 +1,69 @@
name: tests
on:
pull_request:
branches:
- "13.0*"
push:
branches:
- "13.0"
- "13.0-ocabot-*"
jobs:
unreleased-deps:
runs-on: ubuntu-latest
name: Detect unreleased dependencies
steps:
- uses: actions/checkout@v2
- run: |
for reqfile in requirements.txt test-requirements.txt ; do
if [ -f ${reqfile} ] ; then
result=0
# reject non-comment lines that contain a / (i.e. URLs, relative paths)
grep "^[^#].*/" ${reqfile} || result=$?
if [ $result -eq 0 ] ; then
echo "Unreleased dependencies found in ${reqfile}."
exit 1
fi
fi
done
test:
runs-on: ubuntu-latest
container: ${{ matrix.container }}
name: ${{ matrix.name }}
strategy:
fail-fast: false
matrix:
include:
- container: ghcr.io/oca/oca-ci/py3.6-odoo13.0:latest
makepot: "true"
name: test with Odoo
- container: ghcr.io/oca/oca-ci/py3.6-ocb13.0:latest
name: test with OCB
services:
postgres:
image: postgres:9.6
env:
POSTGRES_USER: odoo
POSTGRES_PASSWORD: odoo
POSTGRES_DB: odoo
ports:
- 5432:5432
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
- name: Install addons and dependencies
run: oca_install_addons
- name: Check licenses
run: manifestoo -d . check-licenses
- name: Check development status
run: manifestoo -d . check-dev-status --default-dev-status=Beta
- name: Initialize test db
run: oca_init_test_database
- name: Run tests
run: oca_run_tests
- uses: codecov/codecov-action@v1
- name: Update .pot files
run: oca_export_and_push_pot https://x-access-token:${{ secrets.GIT_PUSH_TOKEN }}@github.com/${{ github.repository }}
if: ${{ matrix.makepot == 'true' && github.event_name == 'push' && github.repository_owner == 'OCA' }}

View File

@ -1,45 +0,0 @@
language: python
cache:
directories:
- $HOME/.cache/pip
- $HOME/.cache/pre-commit
python:
- "3.6"
addons:
postgresql: "9.6"
apt:
packages:
- expect-dev # provides unbuffer utility
- "swig"
- "libreoffice"
stages:
- test
jobs:
include:
- stage: test
env:
- TESTS=1 ODOO_REPO="odoo/odoo" MAKEPOT="1"
- stage: test
env:
- TESTS=1 ODOO_REPO="OCA/OCB"
env:
global:
- VERSION="13.0" TESTS="0" LINT_CHECK="0" MAKEPOT="0"
- WKHTMLTOPDF_VERSION="0.12.5"
- MQT_DEP=PIP
install:
- git clone --depth=1 https://github.com/OCA/maintainer-quality-tools.git
${HOME}/maintainer-quality-tools
- export PATH=${HOME}/maintainer-quality-tools/travis:${PATH}
- travis_install_nightly
script:
- travis_run_tests
after_success:
- travis_after_tests_success

View File

@ -1,6 +1,7 @@
[![Runboat](https://img.shields.io/badge/runboat-Try%20me-875A7B.png)](https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&target_branch=13.0)
[![Build Status](https://travis-ci.com/OCA/reporting-engine.svg?branch=13.0)](https://travis-ci.com/OCA/reporting-engine)
[![Pre-commit Status](https://github.com/OCA/reporting-engine/actions/workflows/pre-commit.yml/badge.svg?branch=13.0)](https://github.com/OCA/reporting-engine/actions/workflows/pre-commit.yml?query=branch%3A13.0)
[![Build Status](https://github.com/OCA/reporting-engine/actions/workflows/test.yml/badge.svg?branch=13.0)](https://github.com/OCA/reporting-engine/actions/workflows/test.yml?query=branch%3A13.0)
[![codecov](https://codecov.io/gh/OCA/reporting-engine/branch/13.0/graph/badge.svg)](https://codecov.io/gh/OCA/reporting-engine)
[![Translation Status](https://translation.odoo-community.org/widgets/reporting-engine-13-0/-/svg-badge.svg)](https://translation.odoo-community.org/engage/reporting-engine-13-0/?utm_source=widget)

View File

@ -10,7 +10,10 @@
"author": "XCG Consulting," "ACSONE SA/NV," "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/reporting-engine",
"depends": ["web"],
"external_dependencies": {"python": ["py3o.template", "py3o.formats", "PyPDF2"]},
"external_dependencies": {
"python": ["py3o.template", "py3o.formats", "PyPDF2"],
"deb": ["libreoffice"],
},
"data": [
"security/ir.model.access.csv",
"views/menu.xml",

View File

@ -9,7 +9,10 @@
"author": "XCG Consulting," "ACSONE SA/NV," "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/reporting-engine",
"depends": ["report_py3o"],
"external_dependencies": {"python": ["py3o.template", "py3o.formats"]},
"external_dependencies": {
"python": ["py3o.template", "py3o.formats"],
"deb": ["libreoffice"],
},
"demo": ["demo/report_py3o.xml", "demo/py3o_pdf_options.xml"],
"data": [
"views/ir_actions_report.xml",

View File

@ -13,7 +13,10 @@
"license": "AGPL-3",
"installable": True,
"depends": ["web_editor"],
"external_dependencies": {"python": ["endesive", "cryptography"]},
"external_dependencies": {
"python": ["endesive", "cryptography"],
"deb": ["default-jre-headless"],
},
"data": [
"data/defaults.xml",
"security/ir.model.access.csv",

View File

@ -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>

View File

@ -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>

View File

@ -39,11 +39,13 @@ class IrActionsReport(models.Model):
"""Obtain the proper certificate for the report and the conditions."""
if self.report_type != "qweb-pdf":
return False
company_id = self.env.company.id
if res_ids:
obj = self.env[self.model].browse(res_ids[0])
if "company_id" in obj:
company_id = obj.company_id.id or company_id
certificates = self.env["report.certificate"].search(
[
("company_id", "=", self.env.user.company_id.id),
("model_id", "=", self.model),
]
[("company_id", "=", company_id), ("model_id", "=", self.model)]
)
if not certificates:
return False
@ -122,8 +124,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 +167,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 +176,10 @@ 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 "{}" -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)

View File

@ -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",

View File

@ -5,3 +5,5 @@
* Pedro M. Baeza
* Jairo Llopis
* David Vidal
* Santi Argüeso <santi@comunitea.com>
* Omar Castiñeira <omar@comunitea.com>

View File

@ -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
++++

View File

@ -1,3 +1,3 @@
To install this module, you need to install Java JDK Headlees, e.g.:
apt-get install openjdk-8-jre-headless
apt-get install default-jre-headless

View File

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

View File

@ -8,3 +8,8 @@ when signing date is important, for example, when signing customer invoices.
You can try the signing with the demo report that is included for customers
called "Test PDF certificate".
You can set extra parameters of JSignPdf library in the system parameter
named 'report_qweb_signer.java_position_parameters', for example '-V' to
visible signature into pdf. You can also set extra parameters for Java in the
system parameter named 'report_qweb_signer.java_parameters'.

Binary file not shown.

View File

@ -2,3 +2,4 @@ py3o.template
py3o.formats
genshi>=0.7
cryptography
endesive