From d1a2d6824debd7949727d12bcae672cefee154f6 Mon Sep 17 00:00:00 2001 From: kobros-tech Date: Sun, 16 Nov 2025 00:42:25 +0300 Subject: [PATCH] [IMP] sign_oca: use mail.template instead of static mails. There is a need to make a well designed email template, in order to encourage partners to sign if the see a professional email. --- sign_oca/README.rst | 6 +- sign_oca/__manifest__.py | 1 + sign_oca/data/mail_template.xml | 101 +++++++++++++++++++++++++ sign_oca/models/sign_oca_request.py | 38 +++------- sign_oca/static/description/index.html | 44 +++++------ sign_oca/templates/assets.xml | 41 ---------- 6 files changed, 134 insertions(+), 97 deletions(-) create mode 100644 sign_oca/data/mail_template.xml diff --git a/sign_oca/README.rst b/sign_oca/README.rst index 5f2430f5..284099a7 100644 --- a/sign_oca/README.rst +++ b/sign_oca/README.rst @@ -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 ======== @@ -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 diff --git a/sign_oca/__manifest__.py b/sign_oca/__manifest__.py index 1d02509b..16166db9 100644 --- a/sign_oca/__manifest__.py +++ b/sign_oca/__manifest__.py @@ -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", diff --git a/sign_oca/data/mail_template.xml b/sign_oca/data/mail_template.xml new file mode 100644 index 00000000..f3c8a11a --- /dev/null +++ b/sign_oca/data/mail_template.xml @@ -0,0 +1,101 @@ + + + + + New document to sign + + {{ object.request_id.create_uid.email or '' }} + {{ object.partner_id.id }} + New document to sign + A notification to sign a document + + + + + + + +
+ + + + + has requested your signature on a document. + + + A document has been requested for your signature. + + + +
+ + + +
+
+ + + + +
+ Warning do not forward this email to other people!
+ They will be able to access this document and sign it as yourself.
+
+
+
+
+ {{ object.request_id.user_id.partner_id.lang }} + +
+ + + + New Document has been signed + + {{ object.request_id.create_uid.email or '' }} + {{ object.partner_id.id }} + New Document has been signed + Notification for signed document + + + + + +
+ + + + () + has sent the signed document. + + + A fully signed document has been sent to you. + + +
+
+ {{ object.request_id.user_id.partner_id.lang }} + +
+
diff --git a/sign_oca/models/sign_oca_request.py b/sign_oca/models/sign_oca_request.py index 26c3c875..d23137cc 100644 --- a/sign_oca/models/sign_oca_request.py +++ b/sign_oca/models/sign_oca_request.py @@ -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( + signer.id, + force_send=True, ) def action_send_signed_request(self): @@ -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): diff --git a/sign_oca/static/description/index.html b/sign_oca/static/description/index.html index 3c284787..b1bce0a8 100644 --- a/sign_oca/static/description/index.html +++ b/sign_oca/static/description/index.html @@ -3,7 +3,7 @@ -README.rst +Sign Oca -
+
+

Sign Oca

- - -Odoo Community Association - -
-

Sign Oca

-

Beta License: AGPL-3 OCA/sign Translate me on Weblate Try me on Runboat

+

Beta License: AGPL-3 OCA/sign Translate me on Weblate Try me on Runboat

This module allows to create documents for signature inside Odoo using OWL.

Table of contents

@@ -404,7 +399,7 @@

Sign Oca

-

Configuration

+

Configuration

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 @@ -412,9 +407,9 @@

Configuration

Sign permissions).

-

Usage

+

Usage

-

Creation of templates

+

Creation of templates

-

Sign role

+

Sign role

  • Access Sign / Settings / Roles
  • Create a new role (Equipment employee for example)
  • @@ -437,7 +432,7 @@

    Sign role

-

Sign a document from template

+

Sign a document from template

-

Sign a pending document

+

Sign a pending document

  • Go to the pencil icon in the upper right corner (systray) of the sign request to access the pending signatures.
  • @@ -465,7 +460,7 @@

    Sign a pending document

-

Sign from template

+

Sign from template

  • Go to any list view or form view (except sign.oca models), e.g.: Contacts
  • @@ -482,7 +477,7 @@

    Sign from template

-

Sign from portal

+

Sign from portal

  • customers who are using portal can sign their documents from portal directly in addition to being able to sign them from emails.
  • @@ -490,9 +485,9 @@

    Sign from portal

-

Known issues / Roadmap

+

Known issues / Roadmap

-

Tasks

+

Tasks

  • Ensure that the signature is inalterable. Maybe we might need to use some tools like endevise or pyHanko with a certificate. Signer can be @@ -501,7 +496,7 @@

    Tasks

-

Bug Tracker

+

Bug Tracker

Bugs are tracked on GitHub Issues. 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 @@ -509,15 +504,15 @@

Bug Tracker

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

-

Credits

+

Credits

-

Authors

+

Authors

  • Dixmit
-

Contributors

+

Contributors

-

Maintainers

+

Maintainers

This module is maintained by the OCA.

Odoo Community Association @@ -546,6 +541,5 @@

Maintainers

-
diff --git a/sign_oca/templates/assets.xml b/sign_oca/templates/assets.xml index 5ac3431c..622bcf3d 100644 --- a/sign_oca/templates/assets.xml +++ b/sign_oca/templates/assets.xml @@ -60,45 +60,4 @@ - -