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
6 changes: 1 addition & 5 deletions sign_oca/README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

========
Sign Oca
========
Expand All @@ -17,7 +13,7 @@ Sign Oca
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
: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
Expand Down
1 change: 1 addition & 0 deletions sign_oca/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"views/sign_portal_oca_templates.xml",
"views/portal_templates.xml",
"data/data.xml",
"data/mail_template.xml",
"wizards/res_config_settings_views.xml",
"data/ir_sequence_data.xml",
"wizards/sign_oca_template_generate.xml",
Expand Down
101 changes: 101 additions & 0 deletions sign_oca/data/mail_template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?xml version="1.0" ?>
Comment thread
pedrobaeza marked this conversation as resolved.
<odoo noupdate="1">
<!-- A mail template for signing a document -->
<record id="email_template_sign_document" model="mail.template">
<field name="name">New document to sign</field>
<field name="model_id" ref="sign_oca.model_sign_oca_request_signer" />
<field name="email_from">{{ object.request_id.create_uid.email or '' }}</field>
<field name="partner_to">{{ object.partner_id.id }}</field>
<field name="subject">New document to sign</field>
<field name="description">A notification to sign a document</field>
<field name="body_html" type="html">
<t t-set="sender" t-value="object.request_id.create_uid" />
<t t-if="sender.name in ['OdooBot', 'Public User']">
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should never use this hard code.... what happens if the user changes the name of OdooBot to MyCompanyBot?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should never use this hard code.... what happens if the user changes the name of OdooBot to MyCompanyBot?

Never underestimate users "creativity" ;-)

<t t-set="sender" t-value="False" />
</t>
<t t-set="link" t-value="object.env.context.get('link')" />
<t t-set="body" t-value="object.env.context.get('body')" />
<div>
<span>
<t t-if="sender">
<t t-out="sender.name" />
<a
t-if="sender.email"
t-att-href="'mailto:%s?subject=%s' % (sender.email, 'Re: %s' % subject)"
style="color:#428BCA; text-decoration:none;"
target="_blank"
><t t-out="sender.email" /></a>
has requested your signature on a document.
</t>
<t t-else="">
A document has been requested for your signature.
</t>
</span>
<span t-if="body">
<div
style="margin: 16px 0px 16px 0px; padding: 8px 16px 8px 16px; background-color: #F1F1F1;"
>
<span>
<t t-out="body" />
</span>
</div>
</span>
<span t-if="link">
<div style="margin:16px auto; text-align:center;">
<a
t-att-href="link"
style="padding: 8px 16px 8px 16px; border-radius: 3px; background-color:#875A7B; text-align:center; text-decoration:none; color: #FFFFFF;"
>
Sign document
</a>
</div>
</span>
<span>
<div style="opacity: 0.7;">
<strong
>Warning</strong> do not forward this email to other people!<br
/>
They will be able to access this document and sign it as yourself.<br
/>
</div>
</span>
</div>
</field>
<field name="lang">{{ object.request_id.user_id.partner_id.lang }}</field>
<field name="auto_delete" eval="False" />
</record>

<!-- A mail template for signed document -->
<record id="email_template_signed_document" model="mail.template">
<field name="name">New Document has been signed</field>
<field name="model_id" ref="sign_oca.model_sign_oca_request_signer" />
<field name="email_from">{{ object.request_id.create_uid.email or '' }}</field>
<field name="partner_to">{{ object.partner_id.id }}</field>
<field name="subject">New Document has been signed</field>
<field name="description">Notification for signed document</field>
<field name="body_html" type="html">
<t t-set="sender" t-value="object.request_id.create_uid" />
<t t-if="sender.name in ['OdooBot', 'Public User']">
<t t-set="sender" t-value="False" />
</t>
<div>
<span>
<t t-if="sender">
<t t-out="sender.name" />
(<a
t-att-href="'mailto:%s?subject=%s' % (sender.email, 'Re: %s' % subject)"
style="color:#428BCA; text-decoration:none;"
target="_blank"
><t t-out="sender.email" /></a>)
has sent the signed document.
</t>
<t t-else="">
A fully signed document has been sent to you.
</t>
</span>
</div>
</field>
<field name="lang">{{ object.request_id.user_id.partner_id.lang }}</field>
<field name="auto_delete" eval="False" />
</record>
</odoo>
38 changes: 12 additions & 26 deletions sign_oca/models/sign_oca_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,19 +258,10 @@ def action_send(self, sign_now=False, message=""):
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",
template = self.env.ref("sign_oca.email_template_sign_document")
template.with_context(body=message, link=signer.access_url).send_mail(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be message_post_with_template?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this method is ok if we log the same message in chatter, I can't use the mail template with sign request, but it is very easy for me and customizable to use with signer model.

you see me setting variables in the start of HTML, then I do the free full customization.

This is what we want so UX team can work straight forward.

signer.id,
force_send=True,
)

def action_send_signed_request(self):
Expand All @@ -292,19 +283,14 @@ 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=_(
"%(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"),
subtype_id=self.env.ref("mail.mt_comment").id,
mail_auto_delete=False,
attachment_ids=attachments.ids,
template = self.env.ref("sign_oca.email_template_signed_document")
email_values = {
"attachment_ids": [(6, 0, attachments.ids)],
}
template.send_mail(
signer.id,
force_send=True,
email_values=email_values,
)

def _check_signed(self):
Expand Down
44 changes: 19 additions & 25 deletions sign_oca/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>README.rst</title>
<title>Sign Oca</title>
<style type="text/css">

/*
Expand Down Expand Up @@ -360,21 +360,16 @@
</style>
</head>
<body>
<div class="document">
<div class="document" id="sign-oca">
<h1 class="title">Sign Oca</h1>


<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
</a>
<div class="section" id="sign-oca">
<h1>Sign Oca</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:4074fa3685a918a90dd5b7bbdde33764b9db4a112ca219352c6265a81b7876cf
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/sign/tree/16.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-16-0/sign-16-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=16.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/16.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-16-0/sign-16-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=16.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 @@ -404,17 +399,17 @@ <h1>Sign Oca</h1>
</ul>
</div>
<div class="section" id="configuration">
<h2><a class="toc-backref" href="#toc-entry-1">Configuration</a></h2>
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<p>There is a wizard (sign.oca.template.generate.multi) that can be used
for any model needed. If there is a template without a linked model or
linked to a model (res.partner for example) an action will be
automatically displayed in the tree and form view (only for users with
Sign permissions).</p>
</div>
<div class="section" id="usage">
<h2><a class="toc-backref" href="#toc-entry-2">Usage</a></h2>
<h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
<div class="section" id="creation-of-templates">
<h3><a class="toc-backref" href="#toc-entry-3">Creation of templates</a></h3>
<h2><a class="toc-backref" href="#toc-entry-3">Creation of templates</a></h2>
<ul class="simple">
<li>Access Sign / Templates</li>
<li>Create a new template</li>
Expand All @@ -426,7 +421,7 @@ <h3><a class="toc-backref" href="#toc-entry-3">Creation of templates</a></h3>
</ul>
</div>
<div class="section" id="sign-role">
<h3><a class="toc-backref" href="#toc-entry-4">Sign role</a></h3>
<h2><a class="toc-backref" href="#toc-entry-4">Sign role</a></h2>
<ul class="simple">
<li>Access Sign / Settings / Roles</li>
<li>Create a new role (Equipment employee for example)</li>
Expand All @@ -437,7 +432,7 @@ <h3><a class="toc-backref" href="#toc-entry-4">Sign role</a></h3>
</ul>
</div>
<div class="section" id="sign-a-document-from-template">
<h3><a class="toc-backref" href="#toc-entry-5">Sign a document from template</a></h3>
<h2><a class="toc-backref" href="#toc-entry-5">Sign a document from template</a></h2>
<ul class="simple">
<li>Access Sign / Templates</li>
<li>Press the Sign button from a template</li>
Expand All @@ -452,7 +447,7 @@ <h3><a class="toc-backref" href="#toc-entry-5">Sign a document from template</a>
</ul>
</div>
<div class="section" id="sign-a-pending-document">
<h3><a class="toc-backref" href="#toc-entry-6">Sign a pending document</a></h3>
<h2><a class="toc-backref" href="#toc-entry-6">Sign a pending document</a></h2>
<ul class="simple">
<li>Go to the pencil icon in the upper right corner (systray) of the sign
request to access the pending signatures.</li>
Expand All @@ -465,7 +460,7 @@ <h3><a class="toc-backref" href="#toc-entry-6">Sign a pending document</a></h3>
</ul>
</div>
<div class="section" id="sign-from-template">
<h3><a class="toc-backref" href="#toc-entry-7">Sign from template</a></h3>
<h2><a class="toc-backref" href="#toc-entry-7">Sign from template</a></h2>
<ul class="simple">
<li>Go to any list view or form view (except sign.oca models), e.g.:
Contacts</li>
Expand All @@ -482,17 +477,17 @@ <h3><a class="toc-backref" href="#toc-entry-7">Sign from template</a></h3>
</ul>
</div>
<div class="section" id="sign-from-portal">
<h3><a class="toc-backref" href="#toc-entry-8">Sign from portal</a></h3>
<h2><a class="toc-backref" href="#toc-entry-8">Sign from portal</a></h2>
<ul class="simple">
<li>customers who are using portal can sign their documents from portal
directly in addition to being able to sign them from emails.</li>
</ul>
</div>
</div>
<div class="section" id="known-issues-roadmap">
<h2><a class="toc-backref" href="#toc-entry-9">Known issues / Roadmap</a></h2>
<h1><a class="toc-backref" href="#toc-entry-9">Known issues / Roadmap</a></h1>
<div class="section" id="tasks">
<h3><a class="toc-backref" href="#toc-entry-10">Tasks</a></h3>
<h2><a class="toc-backref" href="#toc-entry-10">Tasks</a></h2>
<ul class="simple">
<li>Ensure that the signature is inalterable. Maybe we might need to use
some tools like endevise or pyHanko with a certificate. Signer can be
Expand All @@ -501,23 +496,23 @@ <h3><a class="toc-backref" href="#toc-entry-10">Tasks</a></h3>
</div>
</div>
<div class="section" id="bug-tracker">
<h2><a class="toc-backref" href="#toc-entry-11">Bug Tracker</a></h2>
<h1><a class="toc-backref" href="#toc-entry-11">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:%2016.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">
<h2><a class="toc-backref" href="#toc-entry-12">Credits</a></h2>
<h1><a class="toc-backref" href="#toc-entry-12">Credits</a></h1>
<div class="section" id="authors">
<h3><a class="toc-backref" href="#toc-entry-13">Authors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-13">Authors</a></h2>
<ul class="simple">
<li>Dixmit</li>
</ul>
</div>
<div class="section" id="contributors">
<h3><a class="toc-backref" href="#toc-entry-14">Contributors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-14">Contributors</a></h2>
<ul class="simple">
<li>Enric Tobella (<a class="reference external" href="http://www.dixmit.com">www.dixmit.com</a>)</li>
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
Expand All @@ -531,7 +526,7 @@ <h3><a class="toc-backref" href="#toc-entry-14">Contributors</a></h3>
</ul>
</div>
<div class="section" id="maintainers">
<h3><a class="toc-backref" href="#toc-entry-15">Maintainers</a></h3>
<h2><a class="toc-backref" href="#toc-entry-15">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
Expand All @@ -546,6 +541,5 @@ <h3><a class="toc-backref" href="#toc-entry-15">Maintainers</a></h3>
</div>
</div>
</div>
</div>
</body>
</html>
41 changes: 0 additions & 41 deletions sign_oca/templates/assets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,45 +60,4 @@
</div>
</t>
</template>
<template t-name="sign_oca_template_mail">
<div>
<span>
<t t-out="record.create_uid.name" />
(<a
t-att-href="'mailto:%s?subject=%s' % (record.create_uid.email, 'Re: %s' % subject)"
style="color:#428BCA; text-decoration:none;"
target="_blank"
><t t-out="record.create_uid.email" /></a>)
has requested your signature on a document.
</span>
<span t-if="body">
<div
style="margin: 16px 0px 16px 0px; padding: 8px 16px 8px 16px; background-color: #F1F1F1;"
>
<span>
<t t-out="body" />
</span>
</div>
</span>
<span>
<div style="margin:16px auto; text-align:center;">
<a
t-att-href="link"
style="padding: 8px 16px 8px 16px; border-radius: 3px; background-color:#875A7B; text-align:center; text-decoration:none; color: #FFFFFF;"
>
Sign document
</a>
</div>
</span>
<span>
<div style="opacity: 0.7;">
<strong
>Warning</strong> do not forward this email to other people!<br />
They will be able to access this document and sign it as yourself.<br
/>
</div>
</span>
</div>
</template>

</odoo>