Skip to content

Commit d0d79ec

Browse files
committed
[ADD] stamp_sign: created new field in sign module
added new field stamp in the sign module. Moreover, created static component for stamp field. Further, added logic to get the user details if internal user.
1 parent fbf9ee9 commit d0d79ec

File tree

9 files changed

+167
-0
lines changed

9 files changed

+167
-0
lines changed

stamp_sign/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models

stamp_sign/__manifest__.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "Stamp Sign",
3+
"version": "1.0",
4+
"depends": ["sign"],
5+
"category": "Sign",
6+
"data": [
7+
"views/sign_template_views.xml",
8+
"data/sign_data.xml",
9+
],
10+
"assets": {
11+
"sign.assets_pdf_iframe": [
12+
"stamp_sign/static/src/components/**/*",
13+
],
14+
},
15+
"installable": True,
16+
"sequence": 1,
17+
"application": True,
18+
"license": "OEEL-1",
19+
}

stamp_sign/data/sign_data.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<odoo>
3+
<record model="sign.item.type" id="stamp_item_type">
4+
<field name="name">Stamp</field>
5+
<field name="item_type">stamp</field>
6+
<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>
10+
<field name="icon">fa-certificate</field>
11+
</record>
12+
</odoo>

stamp_sign/models/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import sign_template
2+
from . import res_users

stamp_sign/models/res_users.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from odoo import models, api
2+
3+
4+
class ResUsers(models.Model):
5+
_inherit = "res.users"
6+
7+
@api.model
8+
def get_current_user_company_details(self):
9+
user = self.env.user
10+
details = {
11+
"name": user.name,
12+
"company": user.company_id.name if user.company_id else "",
13+
"address": user.company_id.street if user.company_id else "",
14+
"city": user.company_id.city if user.company_id else "",
15+
"country": user.company_id.country_id.name
16+
if user.company_id and user.company_id.country_id
17+
else "",
18+
"vat": user.company_id.vat if user.company_id else "",
19+
}
20+
return details

stamp_sign/models/sign_template.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from odoo import fields, models
2+
3+
4+
class SignItemType(models.Model):
5+
_inherit = "sign.item.type"
6+
7+
item_type = fields.Selection(
8+
selection_add=[
9+
("stamp", "Stamp"),
10+
],
11+
ondelete={"stamp": "set default"},
12+
)
13+
14+
15+
class SignItem(models.Model):
16+
_inherit = "sign.item"
17+
18+
stamp_company = fields.Char("Company")
19+
stamp_address = fields.Char("Address")
20+
stamp_city = fields.Char("City")
21+
stamp_country = fields.Char("Country")
22+
stamp_vat = fields.Char("VAT Number")
23+
stamp_logo = fields.Binary("Stamp Logo")
24+
25+
def _get_stamp_details_for_user(self):
26+
self.ensure_one()
27+
user = self.env.user
28+
details = {}
29+
if user.has_group("base.group_user"):
30+
details = {
31+
"company": user.company_id.name,
32+
"address": user.company_id.street,
33+
"city": user.company_id.city,
34+
"country": user.company_id.country_id.name,
35+
"vat": user.company_id.vat,
36+
}
37+
return details
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<templates xml:space="preserve">
3+
<t t-name="sign.stampItem" t-extend="sign.signItem">
4+
<t t-jquery="t[t-if='readonly']" t-append="true">
5+
<t t-if="type == 'stamp'" t-call="sign.stampSignItem"/>
6+
</t>
7+
8+
<t t-jquery="t[t-if='!readonly']" t-append="true">
9+
<button t-if="type == 'stamp'" t-att-title="role" t-attf-class="{{classes}} o_sign_sign_item text-center" style="color:#757575;" t-att-style="style" t-att-data-stamp="value">
10+
<span class="o_sign_helper"/>
11+
<img t-if="value" t-att-src="value" alt="Stamp"/>
12+
<t t-if="!value">
13+
<span class="o_placeholder ps-0">
14+
<t t-esc="placeholder"/>
15+
</span>
16+
</t>
17+
</button>
18+
</t>
19+
</t>
20+
21+
<div t-name="sign.stampSignItem" t-att-title="role" t-attf-class="{{classes}} o_sign_sign_item" t-att-data-id="id" t-att-style="style" t-att-data-stamp="value">
22+
<div class="sign_item_body">
23+
<span t-if="value" class="o_sign_helper"/>
24+
<img t-if="value" t-att-src="value" alt="Stamp"/>
25+
<t t-if="!value">
26+
<span class="o_placeholder ps-0">
27+
<t t-esc="placeholder"/>
28+
</span>
29+
</t>
30+
<t t-if="editMode" t-call="sign.signItemConfiguration"/>
31+
</div>
32+
</div>
33+
</templates>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/** @odoo-module **/
2+
3+
import { patch } from "@web/core/utils/patch";
4+
import { SignablePDFIframe } from "@sign/components/sign_request/signable_PDF_iframe";
5+
6+
patch(SignablePDFIframe.prototype, {
7+
8+
enableCustom(signItem) {
9+
super.enableCustom(signItem);
10+
11+
const signItemElement = signItem.el;
12+
const signItemData = signItem.data;
13+
const signItemType = this.signItemTypesById[signItemData.type_id];
14+
const { item_type: type } = signItemType;
15+
16+
if (type === "stamp") {
17+
signItemElement.addEventListener("click", (e) => {
18+
this.handleSignatureDialogClick(e.currentTarget, signItemType);
19+
});
20+
}
21+
},
22+
});
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<odoo>
3+
<record id="sign_item_form_view_inherit_stamp" model="ir.ui.view">
4+
<field name="name">sign.item.form.inherit.stamp</field>
5+
<field name="model">sign.item</field>
6+
<field name="inherit_id" ref="sign.sign_item_view_form" />
7+
<field name="arch" type="xml">
8+
<xpath expr="//form//field[@name='responsible_id']" position="after">
9+
<group>
10+
<field name="stamp_logo" widget="image" class="oe_avatar"
11+
invisible="type_id.item_type != 'stamp'" />
12+
<field name="stamp_company" invisible="type_id.item_type != 'stamp'" />
13+
<field name="stamp_address" invisible="type_id.item_type != 'stamp'" />
14+
<field name="stamp_city" invisible="type_id.item_type != 'stamp'" />
15+
<field name="stamp_country" invisible="type_id.item_type != 'stamp'" />
16+
<field name="stamp_vat" invisible="type_id.item_type != 'stamp'" />
17+
</group>
18+
</xpath>
19+
</field>
20+
</record>
21+
</odoo>

0 commit comments

Comments
 (0)