Skip to content

Commit

Permalink
[18.0][MIG] sign_oca: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kobros-tech committed Jan 9, 2025
1 parent f43be30 commit 3953e60
Show file tree
Hide file tree
Showing 33 changed files with 422 additions and 378 deletions.
15 changes: 10 additions & 5 deletions sign_oca/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Sign Oca
: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/17.0/sign_oca
:target: https://github.com/OCA/sign/tree/18.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-17-0/sign-17-0-sign_oca
:target: https://translation.odoo-community.org/projects/sign-18-0/sign-18-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=17.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/sign&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -127,7 +127,7 @@ 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:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/sign/issues/new?body=module:%20sign_oca%0Aversion:%2018.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.

Expand All @@ -143,10 +143,15 @@ Contributors
------------

- Enric Tobella (`www.dixmit.com <http://www.dixmit.com>`__)

- `Tecnativa <https://www.tecnativa.com>`__:

- Víctor Martínez

- `Kencove <https://www.kencove.com>`__:

- Mohamed Alkobrosli

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

Expand All @@ -168,6 +173,6 @@ 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/17.0/sign_oca>`_ project on GitHub.
This module is part of the `OCA/sign <https://github.com/OCA/sign/tree/18.0/sign_oca>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
19 changes: 12 additions & 7 deletions sign_oca/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "Sign Oca",
"summary": """
Allow to sign documents inside Odoo CE""",
"version": "17.0.1.0.0",
"version": "18.0.1.0.0",
"license": "AGPL-3",
"author": "Dixmit,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/sign",
Expand All @@ -32,6 +32,7 @@
],
"assets": {
"web.assets_backend": [
("include", "web._assets_jquery"),
"sign_oca/static/src/components/sign_oca_pdf_common/sign_oca_pdf_common.xml",
"sign_oca/static/src/components/sign_oca_configure/sign_oca_configure.xml",
"sign_oca/static/src/components/sign_oca_pdf/sign_oca_pdf.xml",
Expand All @@ -47,28 +48,33 @@
"sign_oca/static/src/elements/signature.esm.js",
"sign_oca/static/src/elements/check.esm.js",
"sign_oca/static/src/components/sign_oca_pdf/sign_oca_pdf.esm.js",
"sign_oca/static/src/js/*.js",
"sign_oca/static/src/js/sign_oca.esm.js",
"sign_oca/static/src/js/systray_service.esm.js",
"sign_oca/static/src/xml/*.xml",
],
"oca_sign.assets_frontend_sign": [
# frontend needed imports
("include", "web._assets_helpers"),
("include", "web._assets_primary_variables"),
("include", "web._assets_frontend_helpers"),
"web/static/lib/jquery/jquery.js",
"web/static/src/scss/pre_variables.scss",
"web/static/lib/bootstrap/scss/_variables.scss",
"web/static/lib/bootstrap/scss/_variables-dark.scss",
"web/static/lib/bootstrap/scss/_maps.scss",
("include", "web._assets_bootstrap_frontend"),
("include", "web._assets_bootstrap_backend"),
"/web/static/lib/odoo_ui_icons/*",
"/web/static/lib/bootstrap/scss/_functions.scss",
"/web/static/lib/bootstrap/scss/_mixins.scss",
"/web/static/lib/bootstrap/scss/utilities/_api.scss",
"web/static/lib/odoo_ui_icons/*",
"web/static/lib/bootstrap/scss/_functions.scss",
"web/static/lib/bootstrap/scss/_mixins.scss",
"web/static/lib/bootstrap/scss/utilities/_api.scss",
"web/static/src/libs/fontawesome/css/font-awesome.css",
("include", "web._assets_core"),
# especific module frontend imports
"sign_oca/static/src/components/sign_oca_pdf_common/sign_oca_pdf_common.xml",
"sign_oca/static/src/components/sign_oca_configure/sign_oca_configure.xml",
"sign_oca/static/src/components/sign_oca_pdf/sign_oca_pdf.xml",
"sign_oca/static/src/components/sign_oca_pdf_portal/sign_oca_pdf_portal.xml",
"sign_oca/static/src/elements/elements.xml",
"sign_oca/static/src/scss/sign_oca.scss",
"sign_oca/static/src/components/sign_oca_pdf_common/sign_oca_pdf_common.esm.js",
Expand All @@ -77,7 +83,6 @@
"sign_oca/static/src/elements/check.esm.js",
"sign_oca/static/src/components/sign_oca_pdf/sign_oca_pdf.esm.js",
"sign_oca/static/src/components/sign_oca_pdf_portal/sign_oca_pdf_portal.esm.js",
"sign_oca/static/src/components/sign_oca_pdf_portal/sign_oca_pdf_portal.xml",
"sign_oca/static/src/scss/portal.scss",
"sign_oca/static/src/xml/*.xml",
],
Expand Down
1 change: 0 additions & 1 deletion sign_oca/demo/sign_oca_template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<!-- 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>
Expand Down
4 changes: 2 additions & 2 deletions sign_oca/models/res_users.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2023-2024 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import _, api, models, modules
from odoo import api, models, modules


class ResUsers(models.Model):
Expand Down Expand Up @@ -48,7 +48,7 @@ def sign_oca_request_user_count(self):
signers = signer_model.search(signer_group.get("__domain"))
requests["undefined"] = {
"id": False,
"name": _("Undefined"),
"name": self.env._("Undefined"),
"model": "sign.oca.request",
"icon": modules.module.get_module_icon("sign_oca"),
"total_records": len(signers),
Expand Down
66 changes: 44 additions & 22 deletions sign_oca/models/sign_oca_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import hashlib
import json
import logging
from base64 import b64decode, b64encode
from hashlib import sha256
from io import BytesIO
Expand All @@ -14,11 +15,13 @@
from reportlab.pdfgen import canvas
from reportlab.platypus import Image, Paragraph

from odoo import _, api, fields, models
from odoo import api, fields, models
from odoo.exceptions import UserError, ValidationError
from odoo.http import request
from odoo.tools import float_repr

_logger = logging.getLogger(__name__)


class SignOcaRequest(models.Model):
_name = "sign.oca.request"
Expand Down Expand Up @@ -159,10 +162,14 @@ def _ensure_draft(self):
self.ensure_one()
if not self.signer_ids:
raise ValidationError(
_("There are no signers, please fill them before configuring it")
self.env._(
"There are no signers, please fill them before configuring it"
)
)
if not self.state == "draft":
raise ValidationError(_("You can only configure requests in draft state"))
raise ValidationError(
self.env._("You can only configure requests in draft state")
)

def configure(self):
self._ensure_draft()
Expand Down Expand Up @@ -253,7 +260,7 @@ def action_send(self, sign_now=False, message=""):
self.env["mail.thread"].message_notify(
body=render_result,
partner_ids=signer.partner_id.ids,
subject=_("New document to sign"),
subject=self.env._("New document to sign"),
subtype_id=self.env.ref("mail.mt_comment").id,
mail_auto_delete=False,
email_layout_xmlid="mail.mail_notification_light",
Expand Down Expand Up @@ -281,13 +288,13 @@ def action_send_signed_request(self):
# The message will not be linked to the record because we do not want
# it happen.
self.env["mail.thread"].message_notify(
body=_(
body=self.env._(
"%(name)s (%(email)s) has sent the signed document.",
name=self.create_uid.name,
email=self.create_uid.email,
),
partner_ids=signer.partner_id.ids,
subject=_("Signed document"),
subject=self.env._("Signed document"),
subtype_id=self.env.ref("mail.mt_comment").id,
mail_auto_delete=False,
attachment_ids=attachments.ids,
Expand Down Expand Up @@ -413,7 +420,9 @@ def get_info(self, access_token=False):
def sign(self):
self.ensure_one()
if not self.is_allow_signature:
raise ValidationError(_("You are not allowed to sign this document."))
raise ValidationError(
self.env._("You are not allowed to sign this document.")
)
return {
"target": "new",
"type": "ir.actions.act_url",
Expand All @@ -424,10 +433,11 @@ def action_sign(self, items, access_token=False, latitude=False, longitude=False
self.ensure_one()
if self.signed_on:
raise ValidationError(
_("Users %s has already signed the document") % self.partner_id.name
self.env._("Users %s has already signed the document")
% self.partner_id.name
)
if self.request_id.state != "sent":
raise ValidationError(_("Request cannot be signed"))
raise ValidationError(self.env._("Request cannot be signed"))
self.signed_on = fields.Datetime.now()
# current_hash = self.request_id.current_hash
signatory_data = self.request_id.signatory_data
Expand Down Expand Up @@ -488,7 +498,7 @@ def _check_signable(self, item):
if not item["required"]:
return
if not item["value"]:
raise ValidationError(_("Field %s is not filled") % item["name"])
raise ValidationError(self.env._("Field %s is not filled") % item["name"])

def _get_pdf_page_text(self, item, box):
packet = BytesIO()
Expand Down Expand Up @@ -548,23 +558,35 @@ def _get_pdf_page_signature(self, item, box):
can = canvas.Canvas(packet, pagesize=(box.getWidth(), box.getHeight()))
if not item["value"]:
return False
par = Image(
BytesIO(b64decode(item["value"])),
width=item["width"] / 100 * float(box.getWidth()),
height=item["height"] / 100 * float(box.getHeight()),
)
par.drawOn(
can,
item["position_x"] / 100 * float(box.getWidth()),
(100 - item["position_y"] - item["height"]) / 100 * float(box.getHeight()),
)
try:
base64_str = item["value"]
if len(base64_str) % 4:
base64_str += "=" * (4 - len(base64_str) % 4)
if "," in base64_str:
base64_str = item["value"].split(",")[1]
image_data = b64decode(base64_str)
par = Image(
BytesIO(image_data),
width=item["width"] / 100 * float(box.getWidth()),
height=item["height"] / 100 * float(box.getHeight()),
)
par.drawOn(
can,
item["position_x"] / 100 * float(box.getWidth()),
(100 - item["position_y"] - item["height"])
/ 100
* float(box.getHeight()),
)
except Exception as e:
_logger.info(f"Error decoding Base64 string: {e}")
return False
can.save()
packet.seek(0)
new_pdf = PdfFileReader(packet)
return new_pdf.getPage(0)

def _get_pdf_page(self, item, box):
return getattr(self, "_get_pdf_page_%s" % item["field_type"])(item, box)
return getattr(self, f"_get_pdf_page_{ item['field_type'] }")(item, box)

def _set_action_log(self, action, **kwargs):
self.ensure_one()
Expand Down Expand Up @@ -599,7 +621,7 @@ def _get_new_hash(self, secure_seq_number):
)
if prev_sign and len(prev_sign) != 1:
raise UserError(
_(
self.env._(
"An error occurred when computing the inalterability. "
"Impossible to get the unique previous signer information."
)
Expand Down
3 changes: 3 additions & 0 deletions sign_oca/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
- Enric Tobella (www.dixmit.com)
- [Tecnativa](https://www.tecnativa.com):
- Víctor Martínez

- [Kencove](https://www.kencove.com):
- Mohamed Alkobrosli
4 changes: 2 additions & 2 deletions sign_oca/security/security.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<record id="sign_oca_module_category" model="ir.module.category">
<field name="name">Sign</field>
</record>
<!-- Access Groups -->
<record id="sign_oca_group_user" model="res.groups">
<!-- Access Groups -->
<record id="sign_oca_group_user" model="res.groups">
<field name="name">User: Own Documents Only</field>
<field name="category_id" ref="sign_oca_module_category" />
<field name="implied_ids" eval="[(4, ref('base.group_user'))]" />
Expand Down
10 changes: 7 additions & 3 deletions sign_oca/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ <h1 class="title">Sign Oca</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:7989c805e9398580a5c7c493d61eaf2673113bebbe631a090c1bd28088b86aee
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/sign/tree/17.0/sign_oca"><img alt="OCA/sign" src="https://img.shields.io/badge/github-OCA%2Fsign-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/sign-17-0/sign-17-0-sign_oca"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/sign&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/sign/tree/18.0/sign_oca"><img alt="OCA/sign" src="https://img.shields.io/badge/github-OCA%2Fsign-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/sign-18-0/sign-18-0-sign_oca"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/sign&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows to create documents for signature inside Odoo using
OWL.</p>
<p><strong>Table of contents</strong></p>
Expand Down Expand Up @@ -492,7 +492,7 @@ <h1><a class="toc-backref" href="#toc-entry-10">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/sign/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/sign/issues/new?body=module:%20sign_oca%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/sign/issues/new?body=module:%20sign_oca%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand All @@ -511,6 +511,10 @@ <h2><a class="toc-backref" href="#toc-entry-13">Contributors</a></h2>
<li>Víctor Martínez</li>
</ul>
</li>
<li><a class="reference external" href="https://www.kencove.com">Kencove</a>:<ul>
<li>Mohamed Alkobrosli</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand All @@ -524,7 +528,7 @@ <h2><a class="toc-backref" href="#toc-entry-14">Maintainers</a></h2>
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/etobella"><img alt="etobella" src="https://github.com/etobella.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/sign/tree/17.0/sign_oca">OCA/sign</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/sign/tree/18.0/sign_oca">OCA/sign</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<templates xml:space="preserve">
<t t-name="sign_oca.SignOcaConfigureButtons">
<button class="btn btn-primary"><i
class="fa fa-question-circle"
/> Help</button>
class="fa fa-question-circle"
/> Help</button>
<!--
<div
>In order to add a new field, do a right click over the PDF page. You will be able to select the field that you will import</div>
Expand Down Expand Up @@ -38,7 +38,6 @@
/>
<div class="o_sign_oca_resize fa fa-arrows-alt" style="z-index: 90;" />
<span class="o_sign_placeholder" t-out="name" />

</div>
</t>
<t t-name="sign_oca.sign_iframe_contextmenu">
Expand Down Expand Up @@ -75,7 +74,7 @@
In order to add a new field, do a right click over the PDF page. You will be able to select the field that you will import.
Then, you can move and resize the fields over the PDF page using the move icons.
If you do a click over a field, you will be able to change the default configurations of the field<br
/>
/>
Data is saved automatically when editing.
</div>
</xpath>
Expand Down
Loading

0 comments on commit 3953e60

Please sign in to comment.