Skip to content

Commit

Permalink
Merge PR #4 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by etobella
  • Loading branch information
OCA-git-bot committed Sep 26, 2023
2 parents fe412a0 + b3179b2 commit 43526f5
Show file tree
Hide file tree
Showing 55 changed files with 4,199 additions and 0 deletions.
1 change: 1 addition & 0 deletions setup/sign_oca/odoo/addons/sign_oca
6 changes: 6 additions & 0 deletions setup/sign_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,
)
119 changes: 119 additions & 0 deletions sign_oca/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
========
Sign Oca
========

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:d00cef183007ed9fa38ed45a39017a2e6d6e014d9473c803435ed96b4b0757dd
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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/14.0/sign_oca
:alt: OCA/sign
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/sign-14-0/sign-14-0-sign_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=14.0
:alt: Try me on Runboat

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

This module allows to create documents for signature inside Odoo using OWL.

**Table of contents**

.. contents::
:local:

Usage
=====

Creation of templates
~~~~~~~~~~~~~~~~~~~~~

* Access `Sign / Templates`
* Create a new template
* Add a PDF File
* Access the configuration menu
* You can add a field by doing a right click inside a page
* Click on the field in order to delete or edit some configuration of it
* The template is autosaved

Sign a document
~~~~~~~~~~~~~~~

* Access `Sign / Templates`
* Press the `Sign` button from a template
* Fill all the possible partners that will sign the document
* The signature action will be opened.
* There, you can fill all the data you need.
* Once you finish, press the sign button on the top
* When the last signer signs it, the final file will be generated as a PDF

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

Tasks
~~~~~

* Ensure that the signature is inalterable.
Maybe we might need to use some tools like endevise or pyHanko with a certificate.
Signer can be authenticated using OTP.

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_oca%0Aversion:%2014.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 (www.dixmit.com)

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.

.. |maintainer-etobella| image:: https://github.com/etobella.png?size=40px
:target: https://github.com/etobella
:alt: etobella

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-etobella|

This module is part of the `OCA/sign <https://github.com/OCA/sign/tree/14.0/sign_oca>`_ project on GitHub.

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

{
"name": "Sign Oca",
"summary": """
Allow to sign documents inside Odoo CE""",
"version": "14.0.1.0.0",
"license": "AGPL-3",
"author": "Dixmit,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/sign",
"depends": ["web_editor", "portal", "base_sparse_field"],
"data": [
"security/security.xml",
"views/menu.xml",
"data/data.xml",
"wizards/sign_oca_template_generate.xml",
"views/sign_oca_request_log.xml",
"views/sign_oca_request.xml",
"security/ir.model.access.csv",
"views/sign_oca_field.xml",
"views/sign_oca_role.xml",
"views/sign_oca_template.xml",
"templates/assets.xml",
],
"demo": [
"demo/sign_oca_template.xml",
],
"qweb": [
"static/src/components/sign_oca_pdf_common/sign_oca_pdf_common.xml",
"static/src/components/sign_oca_configure/sign_oca_configure.xml",
"static/src/components/sign_oca_pdf/sign_oca_pdf.xml",
"static/src/components/sign_oca_pdf_portal/sign_oca_pdf_portal.xml",
"static/src/elements/elements.xml",
],
"maintainers": ["etobella"],
}
1 change: 1 addition & 0 deletions sign_oca/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import main
110 changes: 110 additions & 0 deletions sign_oca/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import base64
import io

from odoo import http
from odoo.exceptions import AccessError, MissingError
from odoo.http import request

from odoo.addons.base.models.assetsbundle import AssetsBundle
from odoo.addons.portal.controllers.portal import CustomerPortal


class SignController(http.Controller):
@http.route("/sign_oca/get_assets.<any(css,js):ext>", type="http", auth="public")
def get_sign_resources(self, ext):
xmlid = "sign_oca.sign_assets"
files, _remains = request.env["ir.qweb"]._get_asset_content(
xmlid, options=request.context
)
asset = AssetsBundle(xmlid, files)
mock_attachment = getattr(asset, ext)()
if isinstance(
mock_attachment, list
): # suppose that CSS asset will not required to be split in pages
mock_attachment = mock_attachment[0]
_status, headers, content = request.env["ir.http"].binary_content(
id=mock_attachment.id, unique=asset.checksum
)
content_base64 = base64.b64decode(content) if content else ""
headers.append(("Content-Length", len(content_base64)))
return request.make_response(content_base64, headers)


class PortalSign(CustomerPortal):
@http.route(
["/sign_oca/document/<int:signer_id>/<string:access_token>"],
type="http",
auth="public",
website=True,
)
def get_sign_oca_access(self, signer_id, access_token, **kwargs):
try:
signer_sudo = self._document_check_access(
"sign.oca.request.signer", signer_id, access_token
)
except (AccessError, MissingError):
return request.redirect("/my")
if signer_sudo.signed_on:
return request.render(
"sign_oca.portal_sign_document_signed",
{
"signer": signer_sudo,
"company": signer_sudo.request_id.company_id,
},
)
return request.render(
"sign_oca.portal_sign_document",
{
"doc": signer_sudo.request_id,
"partner": signer_sudo.partner_id,
"signer": signer_sudo,
"access_token": access_token,
},
)

@http.route(
["/sign_oca/content/<int:signer_id>/<string:access_token>"],
type="http",
auth="public",
website=True,
)
def get_sign_oca_content_access(self, signer_id, access_token):
try:
signer_sudo = self._document_check_access(
"sign.oca.request.signer", signer_id, access_token
)
except (AccessError, MissingError):
return request.redirect("/my")
data = io.BytesIO(base64.standard_b64decode(signer_sudo.request_id.data))
return http.send_file(data)

@http.route(
["/sign_oca/info/<int:signer_id>/<string:access_token>"],
type="json",
auth="public",
website=True,
)
def get_sign_oca_info_access(self, signer_id, access_token):
try:
signer_sudo = self._document_check_access(
"sign.oca.request.signer", signer_id, access_token
)
except (AccessError, MissingError):
return request.redirect("/my")
return signer_sudo.get_info(access_token=access_token)

@http.route(
["/sign_oca/sign/<int:signer_id>/<string:access_token>"],
type="json",
auth="public",
website=True,
)
def get_sign_oca_sign_access(self, signer_id, access_token, items):
try:
signer_sudo = self._document_check_access(
"sign.oca.request.signer", signer_id, access_token
)
except (AccessError, MissingError):
return request.redirect("/my")
signer_sudo.action_sign(items, access_token=access_token)
return True
37 changes: 37 additions & 0 deletions sign_oca/data/data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="sign_field_name" model="sign.oca.field">
<field name="name">Name</field>
<field name="field_type">text</field>
<field name="default_value">name</field>
</record>
<record id="sign_field_email" model="sign.oca.field">
<field name="name">Email</field>
<field name="field_type">text</field>
<field name="default_value">email</field>
</record>
<record id="sign_field_phone" model="sign.oca.field">
<field name="name">Phone</field>
<field name="field_type">text</field>
<field name="default_value">phone</field>
</record>
<record id="sign_field_text" model="sign.oca.field">
<field name="name">Text</field>
<field name="field_type">text</field>
</record>
<record id="sign_field_signature" model="sign.oca.field">
<field name="name">Signature</field>
<field name="field_type">signature</field>
</record>
<record id="sign_field_check" model="sign.oca.field">
<field name="name">Check</field>
<field name="field_type">check</field>
</record>
<record id="sign_role_customer" model="sign.oca.role">
<field name="name">Customer</field>
<field name="domain">[]</field>
</record>
<record id="sign_role_employee" model="sign.oca.role">
<field name="name">Employee</field>
</record>
</odoo>
12 changes: 12 additions & 0 deletions sign_oca/demo/sign_oca_template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2023 Dixmit
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>

<!-- TODO
<record model="sign.oca.template" id="sign_oca_template_demo_1">
<field name="name">...</field>
</record>
-->

</odoo>
4 changes: 4 additions & 0 deletions sign_oca/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from . import sign_oca_template
from . import sign_oca_role
from . import sign_oca_field
from . import sign_oca_request
17 changes: 17 additions & 0 deletions sign_oca/models/sign_oca_field.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2023 Dixmit
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class SignOcaField(models.Model):
_name = "sign.oca.field"
_description = "Signature Field Type"

name = fields.Char(required=True)
field_type = fields.Selection(
[("text", "Text"), ("signature", "Signature"), ("check", "Check")],
required=True,
default="text",
)
default_value = fields.Char()
Loading

0 comments on commit 43526f5

Please sign in to comment.