Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 22 additions & 15 deletions sign_oca/models/sign_oca_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,23 +255,9 @@ def action_send(self, sign_now=False, message=""):
self._set_action_log("validate")
self.state = "0_sent"
for signer in self.signer_ids:
signer._portal_ensure_token()
if sign_now and signer.partner_id == self.env.user.partner_id:
continue
render_result = self.env["ir.qweb"]._render(
"sign_oca.sign_oca_template_mail",
{"record": signer, "body": message, "link": signer.access_url},
engine="ir.qweb",
minimal_qcontext=True,
)
self.env["mail.thread"].message_notify(
body=render_result,
partner_ids=signer.partner_id.ids,
subject=_("New document to sign"),
subtype_id=self.env.ref("mail.mt_comment").id,
mail_auto_delete=False,
email_layout_xmlid="mail.mail_notification_light",
)
signer.action_send(sign_now, message)

def action_send_signed_request(self):
self.ensure_one()
Expand Down Expand Up @@ -446,6 +432,27 @@ def sign(self):
"url": self.access_url,
}

def action_send(self, sign_now=False, message=""):
self.ensure_one()
if self.signed_on or (sign_now and self.partner_id == self.env.user.partner_id):
return
self._portal_ensure_token()
render_result = self.env["ir.qweb"]._render(
"sign_oca.sign_oca_template_mail",
{"record": self, "body": message, "link": self.access_url},
engine="ir.qweb",
minimal_qcontext=True,
)
# send the message to partners who didn't sign only
self.env["mail.thread"].message_notify(
body=render_result,
partner_ids=self.partner_id.ids,
subject=_("New document to sign"),
subtype_id=self.env.ref("mail.mt_comment").id,
mail_auto_delete=False,
email_layout_xmlid="mail.mail_notification_light",
)

def action_sign(self, items, access_token=False, latitude=False, longitude=False):
self.ensure_one()
if self.signed_on:
Expand Down
33 changes: 33 additions & 0 deletions sign_oca/views/sign_oca_request.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@
<tree editable="bottom">
<field name="role_id" />
<field name="partner_id" />
<button
string="Send"
type="object"
attrs="{'invisible': [('signed_on', '!=', False)]}"
name="action_send"
icon="fa-paper-plane"
Comment thread
kobros-tech marked this conversation as resolved.
confirm="Are you sure ?"
/>
<field name="signed_on" />
</tree>
</field>
Expand Down Expand Up @@ -306,6 +314,15 @@
widget="kanban_activity"
/>
</div>
<button
string="Send"
type="object"
states="1_draft,0_sent"
name="action_send"
icon="fa-paper-plane"
confirm="Are you sure ?"
class="btn btn-primary btn-sm"
/>
</div>
<div class="oe_kanban_bottom_right">
<field
Expand All @@ -331,6 +348,14 @@
<field name="request_id" />
<field name="signed_on" />
<field name="altered_hash" invisible="1" />
<button
string="Send"
type="object"
attrs="{'invisible': [('signed_on', '!=', False)]}"
name="action_send"
icon="fa-paper-plane"
confirm="Are you sure ?"
/>
</tree>
</field>
</record>
Expand All @@ -346,6 +371,14 @@
name="sign"
attrs="{'invisible': [('is_allow_signature', '=', False)]}"
/>
<button
string="Send"
type="object"
attrs="{'invisible': [('signed_on', '!=', False)]}"
name="action_send"
icon="fa-paper-plane"
confirm="Are you sure ?"
/>
</header>
<sheet>
<group>
Expand Down