Skip to content

Commit 75b6bdb

Browse files
committed
[18.0][MIG] sign_oca: Migration to 18.0
1 parent f43be30 commit 75b6bdb

33 files changed

+411
-371
lines changed

sign_oca/README.rst

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ Sign Oca
1717
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
1818
:alt: License: AGPL-3
1919
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsign-lightgray.png?logo=github
20-
:target: https://github.com/OCA/sign/tree/17.0/sign_oca
20+
:target: https://github.com/OCA/sign/tree/18.0/sign_oca
2121
:alt: OCA/sign
2222
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23-
:target: https://translation.odoo-community.org/projects/sign-17-0/sign-17-0-sign_oca
23+
:target: https://translation.odoo-community.org/projects/sign-18-0/sign-18-0-sign_oca
2424
:alt: Translate me on Weblate
2525
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26-
:target: https://runboat.odoo-community.org/builds?repo=OCA/sign&target_branch=17.0
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/sign&target_branch=18.0
2727
:alt: Try me on Runboat
2828

2929
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -127,7 +127,7 @@ Bug Tracker
127127
Bugs are tracked on `GitHub Issues <https://github.com/OCA/sign/issues>`_.
128128
In case of trouble, please check there if your issue has already been reported.
129129
If you spotted it first, help us to smash it by providing a detailed and welcomed
130-
`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**>`_.
130+
`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**>`_.
131131

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

@@ -143,10 +143,15 @@ Contributors
143143
------------
144144

145145
- Enric Tobella (`www.dixmit.com <http://www.dixmit.com>`__)
146+
146147
- `Tecnativa <https://www.tecnativa.com>`__:
147148

148149
- Víctor Martínez
149150

151+
- `Kencove <https://www.kencove.com>`__:
152+
153+
- Mohamed Alkobrosli
154+
150155
Maintainers
151156
-----------
152157

@@ -168,6 +173,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
168173

169174
|maintainer-etobella|
170175

171-
This module is part of the `OCA/sign <https://github.com/OCA/sign/tree/17.0/sign_oca>`_ project on GitHub.
176+
This module is part of the `OCA/sign <https://github.com/OCA/sign/tree/18.0/sign_oca>`_ project on GitHub.
172177

173178
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

sign_oca/__manifest__.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"name": "Sign Oca",
66
"summary": """
77
Allow to sign documents inside Odoo CE""",
8-
"version": "17.0.1.0.0",
8+
"version": "18.0.1.0.0",
99
"license": "AGPL-3",
1010
"author": "Dixmit,Odoo Community Association (OCA)",
1111
"website": "https://github.com/OCA/sign",
@@ -32,6 +32,7 @@
3232
],
3333
"assets": {
3434
"web.assets_backend": [
35+
("include", "web._assets_jquery"),
3536
"sign_oca/static/src/components/sign_oca_pdf_common/sign_oca_pdf_common.xml",
3637
"sign_oca/static/src/components/sign_oca_configure/sign_oca_configure.xml",
3738
"sign_oca/static/src/components/sign_oca_pdf/sign_oca_pdf.xml",
@@ -47,28 +48,33 @@
4748
"sign_oca/static/src/elements/signature.esm.js",
4849
"sign_oca/static/src/elements/check.esm.js",
4950
"sign_oca/static/src/components/sign_oca_pdf/sign_oca_pdf.esm.js",
50-
"sign_oca/static/src/js/*.js",
51+
"sign_oca/static/src/js/sign_oca.esm.js",
52+
"sign_oca/static/src/js/systray_service.esm.js",
5153
"sign_oca/static/src/xml/*.xml",
5254
],
5355
"oca_sign.assets_frontend_sign": [
5456
# frontend needed imports
5557
("include", "web._assets_helpers"),
58+
("include", "web._assets_primary_variables"),
5659
("include", "web._assets_frontend_helpers"),
5760
"web/static/lib/jquery/jquery.js",
5861
"web/static/src/scss/pre_variables.scss",
5962
"web/static/lib/bootstrap/scss/_variables.scss",
63+
"web/static/lib/bootstrap/scss/_variables-dark.scss",
64+
"web/static/lib/bootstrap/scss/_maps.scss",
6065
("include", "web._assets_bootstrap_frontend"),
6166
("include", "web._assets_bootstrap_backend"),
62-
"/web/static/lib/odoo_ui_icons/*",
63-
"/web/static/lib/bootstrap/scss/_functions.scss",
64-
"/web/static/lib/bootstrap/scss/_mixins.scss",
65-
"/web/static/lib/bootstrap/scss/utilities/_api.scss",
67+
"web/static/lib/odoo_ui_icons/*",
68+
"web/static/lib/bootstrap/scss/_functions.scss",
69+
"web/static/lib/bootstrap/scss/_mixins.scss",
70+
"web/static/lib/bootstrap/scss/utilities/_api.scss",
6671
"web/static/src/libs/fontawesome/css/font-awesome.css",
6772
("include", "web._assets_core"),
6873
# especific module frontend imports
6974
"sign_oca/static/src/components/sign_oca_pdf_common/sign_oca_pdf_common.xml",
7075
"sign_oca/static/src/components/sign_oca_configure/sign_oca_configure.xml",
7176
"sign_oca/static/src/components/sign_oca_pdf/sign_oca_pdf.xml",
77+
"sign_oca/static/src/components/sign_oca_pdf_portal/sign_oca_pdf_portal.xml",
7278
"sign_oca/static/src/elements/elements.xml",
7379
"sign_oca/static/src/scss/sign_oca.scss",
7480
"sign_oca/static/src/components/sign_oca_pdf_common/sign_oca_pdf_common.esm.js",
@@ -77,7 +83,6 @@
7783
"sign_oca/static/src/elements/check.esm.js",
7884
"sign_oca/static/src/components/sign_oca_pdf/sign_oca_pdf.esm.js",
7985
"sign_oca/static/src/components/sign_oca_pdf_portal/sign_oca_pdf_portal.esm.js",
80-
"sign_oca/static/src/components/sign_oca_pdf_portal/sign_oca_pdf_portal.xml",
8186
"sign_oca/static/src/scss/portal.scss",
8287
"sign_oca/static/src/xml/*.xml",
8388
],

sign_oca/demo/sign_oca_template.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
<!-- Copyright 2023 Dixmit
33
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
44
<odoo>
5-
65
<!-- TODO
76
<record model="sign.oca.template" id="sign_oca_template_demo_1">
87
<field name="name">...</field>

sign_oca/models/res_users.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright 2023-2024 Tecnativa - Víctor Martínez
22
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
33

4-
from odoo import _, api, models, modules
4+
from odoo import api, models, modules
55

66

77
class ResUsers(models.Model):
@@ -48,7 +48,7 @@ def sign_oca_request_user_count(self):
4848
signers = signer_model.search(signer_group.get("__domain"))
4949
requests["undefined"] = {
5050
"id": False,
51-
"name": _("Undefined"),
51+
"name": self.env._("Undefined"),
5252
"model": "sign.oca.request",
5353
"icon": modules.module.get_module_icon("sign_oca"),
5454
"total_records": len(signers),

sign_oca/models/sign_oca_request.py

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import hashlib
55
import json
6+
import logging
67
from base64 import b64decode, b64encode
78
from hashlib import sha256
89
from io import BytesIO
@@ -14,11 +15,13 @@
1415
from reportlab.pdfgen import canvas
1516
from reportlab.platypus import Image, Paragraph
1617

17-
from odoo import _, api, fields, models
18+
from odoo import api, fields, models
1819
from odoo.exceptions import UserError, ValidationError
1920
from odoo.http import request
2021
from odoo.tools import float_repr
2122

23+
_logger = logging.getLogger(__name__)
24+
2225

2326
class SignOcaRequest(models.Model):
2427
_name = "sign.oca.request"
@@ -159,10 +162,14 @@ def _ensure_draft(self):
159162
self.ensure_one()
160163
if not self.signer_ids:
161164
raise ValidationError(
162-
_("There are no signers, please fill them before configuring it")
165+
self.env._(
166+
"There are no signers, please fill them before configuring it"
167+
)
163168
)
164169
if not self.state == "draft":
165-
raise ValidationError(_("You can only configure requests in draft state"))
170+
raise ValidationError(
171+
self.env._("You can only configure requests in draft state")
172+
)
166173

167174
def configure(self):
168175
self._ensure_draft()
@@ -253,7 +260,7 @@ def action_send(self, sign_now=False, message=""):
253260
self.env["mail.thread"].message_notify(
254261
body=render_result,
255262
partner_ids=signer.partner_id.ids,
256-
subject=_("New document to sign"),
263+
subject=self.env._("New document to sign"),
257264
subtype_id=self.env.ref("mail.mt_comment").id,
258265
mail_auto_delete=False,
259266
email_layout_xmlid="mail.mail_notification_light",
@@ -281,13 +288,13 @@ def action_send_signed_request(self):
281288
# The message will not be linked to the record because we do not want
282289
# it happen.
283290
self.env["mail.thread"].message_notify(
284-
body=_(
291+
body=self.env._(
285292
"%(name)s (%(email)s) has sent the signed document.",
286293
name=self.create_uid.name,
287294
email=self.create_uid.email,
288295
),
289296
partner_ids=signer.partner_id.ids,
290-
subject=_("Signed document"),
297+
subject=self.env._("Signed document"),
291298
subtype_id=self.env.ref("mail.mt_comment").id,
292299
mail_auto_delete=False,
293300
attachment_ids=attachments.ids,
@@ -413,7 +420,9 @@ def get_info(self, access_token=False):
413420
def sign(self):
414421
self.ensure_one()
415422
if not self.is_allow_signature:
416-
raise ValidationError(_("You are not allowed to sign this document."))
423+
raise ValidationError(
424+
self.env._("You are not allowed to sign this document.")
425+
)
417426
return {
418427
"target": "new",
419428
"type": "ir.actions.act_url",
@@ -424,10 +433,11 @@ def action_sign(self, items, access_token=False, latitude=False, longitude=False
424433
self.ensure_one()
425434
if self.signed_on:
426435
raise ValidationError(
427-
_("Users %s has already signed the document") % self.partner_id.name
436+
self.env._("Users %s has already signed the document")
437+
% self.partner_id.name
428438
)
429439
if self.request_id.state != "sent":
430-
raise ValidationError(_("Request cannot be signed"))
440+
raise ValidationError(self.env._("Request cannot be signed"))
431441
self.signed_on = fields.Datetime.now()
432442
# current_hash = self.request_id.current_hash
433443
signatory_data = self.request_id.signatory_data
@@ -488,7 +498,7 @@ def _check_signable(self, item):
488498
if not item["required"]:
489499
return
490500
if not item["value"]:
491-
raise ValidationError(_("Field %s is not filled") % item["name"])
501+
raise ValidationError(self.env._("Field %s is not filled") % item["name"])
492502

493503
def _get_pdf_page_text(self, item, box):
494504
packet = BytesIO()
@@ -548,23 +558,35 @@ def _get_pdf_page_signature(self, item, box):
548558
can = canvas.Canvas(packet, pagesize=(box.getWidth(), box.getHeight()))
549559
if not item["value"]:
550560
return False
551-
par = Image(
552-
BytesIO(b64decode(item["value"])),
553-
width=item["width"] / 100 * float(box.getWidth()),
554-
height=item["height"] / 100 * float(box.getHeight()),
555-
)
556-
par.drawOn(
557-
can,
558-
item["position_x"] / 100 * float(box.getWidth()),
559-
(100 - item["position_y"] - item["height"]) / 100 * float(box.getHeight()),
560-
)
561+
try:
562+
base64_str = item["value"]
563+
if len(base64_str) % 4:
564+
base64_str += "=" * (4 - len(base64_str) % 4)
565+
if "," in base64_str:
566+
base64_str = item["value"].split(",")[1]
567+
image_data = b64decode(base64_str)
568+
par = Image(
569+
BytesIO(image_data),
570+
width=item["width"] / 100 * float(box.getWidth()),
571+
height=item["height"] / 100 * float(box.getHeight()),
572+
)
573+
par.drawOn(
574+
can,
575+
item["position_x"] / 100 * float(box.getWidth()),
576+
(100 - item["position_y"] - item["height"])
577+
/ 100
578+
* float(box.getHeight()),
579+
)
580+
except Exception as e:
581+
_logger.info(f"Error decoding Base64 string: {e}")
582+
return False
561583
can.save()
562584
packet.seek(0)
563585
new_pdf = PdfFileReader(packet)
564586
return new_pdf.getPage(0)
565587

566588
def _get_pdf_page(self, item, box):
567-
return getattr(self, "_get_pdf_page_%s" % item["field_type"])(item, box)
589+
return getattr(self, f"_get_pdf_page_{ item['field_type'] }")(item, box)
568590

569591
def _set_action_log(self, action, **kwargs):
570592
self.ensure_one()
@@ -599,7 +621,7 @@ def _get_new_hash(self, secure_seq_number):
599621
)
600622
if prev_sign and len(prev_sign) != 1:
601623
raise UserError(
602-
_(
624+
self.env._(
603625
"An error occurred when computing the inalterability. "
604626
"Impossible to get the unique previous signer information."
605627
)

sign_oca/readme/CONTRIBUTORS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
- Enric Tobella (www.dixmit.com)
22
- [Tecnativa](https://www.tecnativa.com):
33
- Víctor Martínez
4+
5+
- [Kencove](https://www.kencove.com):
6+
- Mohamed Alkobrosli

sign_oca/security/security.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<record id="sign_oca_module_category" model="ir.module.category">
55
<field name="name">Sign</field>
66
</record>
7-
<!-- Access Groups -->
8-
<record id="sign_oca_group_user" model="res.groups">
7+
<!-- Access Groups -->
8+
<record id="sign_oca_group_user" model="res.groups">
99
<field name="name">User: Own Documents Only</field>
1010
<field name="category_id" ref="sign_oca_module_category" />
1111
<field name="implied_ids" eval="[(4, ref('base.group_user'))]" />

sign_oca/static/description/index.html

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ <h1 class="title">Sign Oca</h1>
369369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370370
!! source digest: sha256:7989c805e9398580a5c7c493d61eaf2673113bebbe631a090c1bd28088b86aee
371371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
372-
<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>
372+
<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>
373373
<p>This module allows to create documents for signature inside Odoo using
374374
OWL.</p>
375375
<p><strong>Table of contents</strong></p>
@@ -492,7 +492,7 @@ <h1><a class="toc-backref" href="#toc-entry-10">Bug Tracker</a></h1>
492492
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/sign/issues">GitHub Issues</a>.
493493
In case of trouble, please check there if your issue has already been reported.
494494
If you spotted it first, help us to smash it by providing a detailed and welcomed
495-
<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>
495+
<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>
496496
<p>Do not contact contributors directly about support or help with technical issues.</p>
497497
</div>
498498
<div class="section" id="credits">
@@ -511,6 +511,10 @@ <h2><a class="toc-backref" href="#toc-entry-13">Contributors</a></h2>
511511
<li>Víctor Martínez</li>
512512
</ul>
513513
</li>
514+
<li><a class="reference external" href="https://www.kencove.com">Kencove</a>:<ul>
515+
<li>Mohamed Alkobrosli</li>
516+
</ul>
517+
</li>
514518
</ul>
515519
</div>
516520
<div class="section" id="maintainers">
@@ -524,7 +528,7 @@ <h2><a class="toc-backref" href="#toc-entry-14">Maintainers</a></h2>
524528
promote its widespread use.</p>
525529
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
526530
<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>
527-
<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>
531+
<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>
528532
<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>
529533
</div>
530534
</div>

sign_oca/static/src/components/sign_oca_configure/sign_oca_configure.xml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<templates xml:space="preserve">
33
<t t-name="sign_oca.SignOcaConfigureButtons">
44
<button class="btn btn-primary"><i
5-
class="fa fa-question-circle"
6-
/> Help</button>
5+
class="fa fa-question-circle"
6+
/> Help</button>
77
<!--
88
<div
99
>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>
@@ -38,7 +38,6 @@
3838
/>
3939
<div class="o_sign_oca_resize fa fa-arrows-alt" style="z-index: 90;" />
4040
<span class="o_sign_placeholder" t-out="name" />
41-
4241
</div>
4342
</t>
4443
<t t-name="sign_oca.sign_iframe_contextmenu">
@@ -75,7 +74,7 @@
7574
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.
7675
Then, you can move and resize the fields over the PDF page using the move icons.
7776
If you do a click over a field, you will be able to change the default configurations of the field<br
78-
/>
77+
/>
7978
Data is saved automatically when editing.
8079
</div>
8180
</xpath>

0 commit comments

Comments
 (0)