From 32d8bdeae80559c58faf1be66b668f37c7dda89c Mon Sep 17 00:00:00 2001 From: BernatPForgeFlow Date: Wed, 22 May 2024 16:38:34 +0200 Subject: [PATCH 1/2] [IMP] sign_oca: Send to signers the final signed document Once the request is completely signed, all the signers should receive a copy of the final document. --- sign_oca/__manifest__.py | 1 + sign_oca/models/__init__.py | 1 + sign_oca/models/res_company.py | 14 ++++++++ sign_oca/models/sign_oca_request.py | 35 ++++++++++++++++++ sign_oca/wizards/__init__.py | 1 + sign_oca/wizards/res_config_settings.py | 12 +++++++ .../wizards/res_config_settings_views.xml | 36 +++++++++++++++++++ 7 files changed, 100 insertions(+) create mode 100644 sign_oca/models/res_company.py create mode 100644 sign_oca/wizards/res_config_settings.py create mode 100644 sign_oca/wizards/res_config_settings_views.xml diff --git a/sign_oca/__manifest__.py b/sign_oca/__manifest__.py index 95a3faff..9c49c674 100644 --- a/sign_oca/__manifest__.py +++ b/sign_oca/__manifest__.py @@ -14,6 +14,7 @@ "security/security.xml", "views/menu.xml", "data/data.xml", + "wizards/res_config_settings_views.xml", "wizards/sign_oca_template_generate.xml", "wizards/sign_oca_template_generate_multi.xml", "views/res_partner_views.xml", diff --git a/sign_oca/models/__init__.py b/sign_oca/models/__init__.py index 32aa7235..1cbaaba0 100644 --- a/sign_oca/models/__init__.py +++ b/sign_oca/models/__init__.py @@ -1,3 +1,4 @@ +from . import res_company from . import res_users from . import res_partner from . import sign_oca_template diff --git a/sign_oca/models/res_company.py b/sign_oca/models/res_company.py new file mode 100644 index 00000000..6b21ca54 --- /dev/null +++ b/sign_oca/models/res_company.py @@ -0,0 +1,14 @@ +# Copyright 2024 ForgeFlow S.L. (http://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from odoo import fields, models + + +class ResCompany(models.Model): + _inherit = "res.company" + + sign_oca_send_sign_request_copy = fields.Boolean( + string="Send signers a copy of the final signed document", + help="Once all signers have signed the request, a copy of " + "the final document will be sent to each of them.", + ) diff --git a/sign_oca/models/sign_oca_request.py b/sign_oca/models/sign_oca_request.py index cb84bc8c..e0459704 100644 --- a/sign_oca/models/sign_oca_request.py +++ b/sign_oca/models/sign_oca_request.py @@ -270,6 +270,40 @@ def action_send(self, sign_now=False, message=""): email_layout_xmlid="mail.mail_notification_light", ) + def action_send_signed_request(self): + self.ensure_one() + if ( + self.state != "signed" + or not self.env.company.sign_oca_send_sign_request_copy + ): + return + for signer in self.signer_ids: + attachments = ( + self.env["ir.attachment"] + .sudo() + .search( + [ + ("res_model", "=", "sign.oca.request"), + ("res_id", "=", self.id), + ("res_field", "=", "data"), + ] + ) + ) + # 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, + ) + def _check_signed(self): self.ensure_one() if self.state != "sent": @@ -431,6 +465,7 @@ def action_sign(self, items, access_token=False): self.signature_hash = final_hash self.request_id._check_signed() self._set_action_log("sign", access_token=access_token) + self.request_id.action_send_signed_request() return { "type": "ir.actions.act_url", "url": self.access_url, diff --git a/sign_oca/wizards/__init__.py b/sign_oca/wizards/__init__.py index b173f2c6..8d660153 100644 --- a/sign_oca/wizards/__init__.py +++ b/sign_oca/wizards/__init__.py @@ -1,2 +1,3 @@ +from . import res_config_settings from . import sign_oca_template_generate from . import sign_oca_template_generate_multi diff --git a/sign_oca/wizards/res_config_settings.py b/sign_oca/wizards/res_config_settings.py new file mode 100644 index 00000000..bb023922 --- /dev/null +++ b/sign_oca/wizards/res_config_settings.py @@ -0,0 +1,12 @@ +# Copyright 2024 ForgeFlow S.L. (http://www.forgeflow.com) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + _inherit = "res.config.settings" + + sign_oca_send_sign_request_copy = fields.Boolean( + related="company_id.sign_oca_send_sign_request_copy", readonly=False + ) diff --git a/sign_oca/wizards/res_config_settings_views.xml b/sign_oca/wizards/res_config_settings_views.xml new file mode 100644 index 00000000..ac400800 --- /dev/null +++ b/sign_oca/wizards/res_config_settings_views.xml @@ -0,0 +1,36 @@ + + + + + res.config.settings.view.form (in sign_oca) + res.config.settings + + + +
+

Sign Requests

+
+
+
+ +
+
+
+
+
+
+
+
+
+
From 0e029482809b4ab9f9e53725d02825a93891a029 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Fri, 11 Oct 2024 11:51:08 +0200 Subject: [PATCH 2/2] [IMP] sign_oca: Add General settings menu item TT41745 --- sign_oca/__manifest__.py | 2 +- sign_oca/static/description/index.html | 11 ++++------- sign_oca/views/menu.xml | 11 +++++++++-- .../res_config_settings_views.xml | 15 +++++++++++++++ sign_oca/views/sign_oca_field.xml | 13 +++++++------ sign_oca/views/sign_oca_role.xml | 13 +++++++------ 6 files changed, 43 insertions(+), 22 deletions(-) rename sign_oca/{wizards => views}/res_config_settings_views.xml (73%) diff --git a/sign_oca/__manifest__.py b/sign_oca/__manifest__.py index 9c49c674..b4ad4240 100644 --- a/sign_oca/__manifest__.py +++ b/sign_oca/__manifest__.py @@ -14,9 +14,9 @@ "security/security.xml", "views/menu.xml", "data/data.xml", - "wizards/res_config_settings_views.xml", "wizards/sign_oca_template_generate.xml", "wizards/sign_oca_template_generate_multi.xml", + "views/res_config_settings_views.xml", "views/res_partner_views.xml", "views/sign_oca_request_log.xml", "views/sign_oca_request.xml", diff --git a/sign_oca/static/description/index.html b/sign_oca/static/description/index.html index f82e98fa..43c66281 100644 --- a/sign_oca/static/description/index.html +++ b/sign_oca/static/description/index.html @@ -8,11 +8,10 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ +:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. -Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -275,7 +274,7 @@ margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: gray; } /* line numbers */ +pre.code .ln { color: grey; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -301,7 +300,7 @@ span.pre { white-space: pre } -span.problematic, pre.problematic { +span.problematic { color: red } span.section-subtitle { @@ -505,9 +504,7 @@

Contributors

Maintainers

This module is maintained by the OCA.

- -Odoo Community Association - +Odoo Community Association

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

diff --git a/sign_oca/views/menu.xml b/sign_oca/views/menu.xml index 411e2a8f..6fc13da9 100644 --- a/sign_oca/views/menu.xml +++ b/sign_oca/views/menu.xml @@ -11,10 +11,17 @@ sequence="16" groups="sign_oca.sign_oca_group_user" /> - + + diff --git a/sign_oca/wizards/res_config_settings_views.xml b/sign_oca/views/res_config_settings_views.xml similarity index 73% rename from sign_oca/wizards/res_config_settings_views.xml rename to sign_oca/views/res_config_settings_views.xml index ac400800..8a1146ec 100644 --- a/sign_oca/wizards/res_config_settings_views.xml +++ b/sign_oca/views/res_config_settings_views.xml @@ -33,4 +33,19 @@ + + General Settings + ir.actions.act_window + res.config.settings + form + inline + {'module' : 'sign_oca'} + + diff --git a/sign_oca/views/sign_oca_field.xml b/sign_oca/views/sign_oca_field.xml index 2f4caa82..8bb1216c 100644 --- a/sign_oca/views/sign_oca_field.xml +++ b/sign_oca/views/sign_oca_field.xml @@ -46,10 +46,11 @@ [] {} - - Fields - - - - + diff --git a/sign_oca/views/sign_oca_role.xml b/sign_oca/views/sign_oca_role.xml index 31f6b490..c333fff4 100644 --- a/sign_oca/views/sign_oca_role.xml +++ b/sign_oca/views/sign_oca_role.xml @@ -57,10 +57,11 @@ [] {} - - Roles - - - - +