Skip to content

Commit c805f25

Browse files
committed
[IMP] stamp_sign: added values in stamp dialog & generated its stamp sign
added auto-filling of user details (if internal user) in the stamp dialog. Furthermore, generated a stamp sign based on the user's details and logo, if provided. Moreover, changed the default fonts of the stamp signature.
1 parent 39601a8 commit c805f25

19 files changed

+795
-320
lines changed

stamp_sign/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"category": "Sign",
66
"data": [
77
"data/sign_data.xml",
8-
"views/sign_template_views.xml",
8+
"views/sign_request_templates.xml",
99
],
1010
"assets": {
1111
"web.assets_backend": [

stamp_sign/controllers/main.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from odoo.addons.sign.controllers.main import Sign
33

44

5-
class SignController(Sign):
5+
class Sign(Sign):
66
def get_document_qweb_context(self, sign_request_id, token, **post):
77
data = super().get_document_qweb_context(sign_request_id, token, **post)
88
current_request_item = data["current_request_item"]
@@ -28,3 +28,29 @@ def get_document_qweb_context(self, sign_request_id, token, **post):
2828
)
2929

3030
return data
31+
32+
@http.route(["/sign/update_user_signature"], type="json", auth="user")
33+
def update_signature(
34+
self, sign_request_id, role, signature_type=None, datas=None, frame_datas=None
35+
):
36+
sign_request_item_sudo = (
37+
http.request.env["sign.request.item"]
38+
.sudo()
39+
.search(
40+
[("sign_request_id", "=", sign_request_id), ("role_id", "=", role)],
41+
limit=1,
42+
)
43+
)
44+
user = http.request.env.user
45+
allowed = sign_request_item_sudo.partner_id.id == user.partner_id.id
46+
if (
47+
not allowed
48+
or signature_type
49+
not in ["sign_signature", "sign_initials", "stamp_sign_stamp"]
50+
or not user
51+
):
52+
return False
53+
user[signature_type] = datas[datas.find(",") + 1 :]
54+
if frame_datas:
55+
user[signature_type + "_frame"] = frame_datas[frame_datas.find(",") + 1 :]
56+
return True

stamp_sign/data/sign_data.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
<field name="name">Stamp</field>
55
<field name="item_type">stamp</field>
66
<field name="tip">stamp</field>
7-
<field name="placeholder">Stamp It</field>
8-
<field name="default_width" type="float">0.200</field>
9-
<field name="default_height" type="float">0.050</field>
7+
<field name="placeholder">Stamp</field>
8+
<field name="default_width" type="float">0.300</field>
9+
<field name="default_height" type="float">0.10</field>
1010
<field name="icon">fa-certificate</field>
1111
</record>
1212
</odoo>

stamp_sign/models/res_users.py

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,22 @@
1-
from odoo import models, api, fields
2-
import base64
1+
from odoo import models, fields
2+
3+
SIGN_USER_FIELDS = ["stamp_sign"]
34

45

56
class ResUsers(models.Model):
67
_inherit = "res.users"
78

8-
stamp_sign = fields.Binary(string="Digital Stamp", copy=False, groups="base.group_user")
9-
stamp_sign_frame = fields.Binary(string="Digital Stamp Frame", copy=False, groups="base.group_user")
9+
@property
10+
def SELF_READABLE_FIELDS(self):
11+
return super().SELF_READABLE_FIELDS + SIGN_USER_FIELDS
12+
13+
@property
14+
def SELF_WRITEABLE_FIELDS(self):
15+
return super().SELF_WRITEABLE_FIELDS + SIGN_USER_FIELDS
1016

11-
@api.model
12-
def get_current_user_company_details(self):
13-
user = self.env.user
14-
details = {
15-
"name": user.name,
16-
"company": user.company_id.name if user.company_id else "",
17-
"address": user.company_id.street if user.company_id else "",
18-
"city": user.company_id.city if user.company_id else "",
19-
"country": user.company_id.country_id.name
20-
if user.company_id and user.company_id.country_id
21-
else "",
22-
"vat": user.company_id.vat if user.company_id else "",
23-
"logo_url": False,
24-
}
25-
if user.company_id and user.company_id.logo:
26-
details["logo_url"] = "data:image/png;base64," + base64.b64encode(
27-
user.company_id.logo
28-
).decode("utf-8")
29-
return details
17+
stamp_sign_stamp = fields.Binary(
18+
string="Company Stamp", copy=False, groups="base.group_user"
19+
)
20+
stamp_sign_stamp_frame = fields.Binary(
21+
string="Company Stamp Frame", copy=False, groups="base.group_user"
22+
)

0 commit comments

Comments
 (0)