Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][ADD] sign_biometric_oca: Proof of Concept #14

Open
wants to merge 3 commits into
base: 16.0
Choose a base branch
from
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
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# generated from manifests external_dependencies
svglib
1 change: 1 addition & 0 deletions setup/sign_biometric_oca/odoo/addons/sign_biometric_oca
6 changes: 6 additions & 0 deletions setup/sign_biometric_oca/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,
)
76 changes: 76 additions & 0 deletions sign_biometric_oca/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
==================
Sign Biometric Oca
==================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:1a1329c3d712379ddbc489e3c1499da3721b4b6ffae51187a8fd5afeb42d5bc8
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsign-lightgray.png?logo=github
:target: https://github.com/OCA/sign/tree/16.0/sign_biometric_oca
:alt: OCA/sign
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/sign-16-0/sign-16-0-sign_biometric_oca
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/sign&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

Allow to generate biometric signatures with OCA Sign Application.

**Table of contents**

.. contents::
:local:

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/sign/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/sign/issues/new?body=module:%20sign_biometric_oca%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Dixmit

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

- Enric Tobella

Maintainers
-----------

This module is maintained by the OCA.

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

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/sign <https://github.com/OCA/sign/tree/16.0/sign_biometric_oca>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions sign_biometric_oca/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
36 changes: 36 additions & 0 deletions sign_biometric_oca/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright 2023 Dixmit
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Sign Biometric Oca",
"summary": """
Add a new widget in order to store biometric information""",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "Dixmit,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/sign",
"depends": [
"sign_oca",
],
"data": [
"data/data.xml",
],
"demo": [],
"external_dependencies": {"python": ["svglib"]},
"assets": {
"web.assets_backend": [
"sign_biometric_oca/static/src/lib/perfect-freehand.esm.js",
"sign_biometric_oca/static/src/components/biometric_signature_dialog.xml",
"sign_biometric_oca/static/src/components/biometric_signature_dialog.esm.js",
"sign_biometric_oca/static/src/components/biometric.esm.js",
"sign_biometric_oca/static/src/components/biometric.scss",
],
"web.assets_frontend": [
"sign_biometric_oca/static/src/lib/perfect-freehand.esm.js",
"sign_biometric_oca/static/src/components/biometric_signature_dialog.xml",
"sign_biometric_oca/static/src/components/biometric_signature_dialog.esm.js",
"sign_biometric_oca/static/src/components/biometric.esm.js",
"sign_biometric_oca/static/src/components/biometric.scss",
],
},
}
7 changes: 7 additions & 0 deletions sign_biometric_oca/data/data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="sign_field_biometric" model="sign.oca.field">
<field name="name">Biometric Signature</field>
<field name="field_type">biometric</field>
</record>
</odoo>
2 changes: 2 additions & 0 deletions sign_biometric_oca/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import sign_oca_field
from . import sign_oca_request
13 changes: 13 additions & 0 deletions sign_biometric_oca/models/sign_oca_field.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2023 Dixmit
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class SignOcaField(models.Model):
_inherit = "sign.oca.field"

field_type = fields.Selection(
selection_add=[("biometric", "Biometric")],
ondelete={"biometric": "set default"},
)
39 changes: 39 additions & 0 deletions sign_biometric_oca/models/sign_oca_request.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright 2023 Dixmit
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from base64 import b64decode
from io import BytesIO

from PyPDF2 import PdfFileReader
from reportlab.pdfgen import canvas
from svglib.svglib import svg2rlg

from odoo import models


class SignOcaRequestSigner(models.Model):

_inherit = "sign.oca.request.signer"

def _get_pdf_page_biometric(self, item, box):
packet = BytesIO()
can = canvas.Canvas(packet, pagesize=(box.getWidth(), box.getHeight()))

Check warning on line 20 in sign_biometric_oca/models/sign_oca_request.py

View check run for this annotation

Codecov / codecov/patch

sign_biometric_oca/models/sign_oca_request.py#L19-L20

Added lines #L19 - L20 were not covered by tests
if not item.get("value"):
return False
drawing = svg2rlg(BytesIO(b64decode(item["value"])))
scaling_x = item["width"] / 100 * float(box.getWidth()) / drawing.width
scaling_y = item["height"] / 100 * float(box.getHeight()) / drawing.height

Check warning on line 25 in sign_biometric_oca/models/sign_oca_request.py

View check run for this annotation

Codecov / codecov/patch

sign_biometric_oca/models/sign_oca_request.py#L22-L25

Added lines #L22 - L25 were not covered by tests

drawing.width = item["width"] / 100 * float(box.getWidth())
drawing.height = item["height"] / 100 * float(box.getHeight())
drawing.scale(scaling_x, scaling_y)

Check warning on line 29 in sign_biometric_oca/models/sign_oca_request.py

View check run for this annotation

Codecov / codecov/patch

sign_biometric_oca/models/sign_oca_request.py#L27-L29

Added lines #L27 - L29 were not covered by tests

drawing.drawOn(

Check warning on line 31 in sign_biometric_oca/models/sign_oca_request.py

View check run for this annotation

Codecov / codecov/patch

sign_biometric_oca/models/sign_oca_request.py#L31

Added line #L31 was not covered by tests
can,
item["position_x"] / 100 * float(box.getWidth()),
(100 - item["position_y"] - item["height"]) / 100 * float(box.getHeight()),
)
can.save()
packet.seek(0)
new_pdf = PdfFileReader(packet)
return new_pdf.getPage(0)

Check warning on line 39 in sign_biometric_oca/models/sign_oca_request.py

View check run for this annotation

Codecov / codecov/patch

sign_biometric_oca/models/sign_oca_request.py#L36-L39

Added lines #L36 - L39 were not covered by tests
1 change: 1 addition & 0 deletions sign_biometric_oca/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Enric Tobella
1 change: 1 addition & 0 deletions sign_biometric_oca/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow to generate biometric signatures with OCA Sign Application.
Binary file added sign_biometric_oca/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.
Loading
Loading