From 69826e094d24de7a3607e38e2777cdcf6c24afb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Estefan=C3=ADa=20Bauz=C3=A1=20Ill=C3=A1n?= Date: Tue, 2 Jun 2026 12:10:54 +0200 Subject: [PATCH] [IMP] hr_appraisal_oca: add configurable email notifications --- hr_appraisal_oca/README.rst | 22 +++++++-- hr_appraisal_oca/i18n/es.po | 10 ++++ hr_appraisal_oca/i18n/hr_appraisal_oca.pot | 10 ++++ hr_appraisal_oca/models/hr_appraisal.py | 16 +++++++ hr_appraisal_oca/readme/USAGE.md | 13 ++++++ .../static/description/index.html | 38 ++++++++------- hr_appraisal_oca/tests/test_hr_appraisal.py | 46 +++++++++++++++++++ .../views/hr_appraisal_form_view.xml | 6 +++ 8 files changed, 140 insertions(+), 21 deletions(-) diff --git a/hr_appraisal_oca/README.rst b/hr_appraisal_oca/README.rst index 07540d943fb..9cded8b8766 100644 --- a/hr_appraisal_oca/README.rst +++ b/hr_appraisal_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 - ============= Appraisal Oca ============= @@ -17,7 +13,7 @@ Appraisal 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%2Fhr-lightgray.png?logo=github @@ -148,6 +144,22 @@ click Restore. Archiving does not delete the record; you can archive or restore appraisals at any time. +8. Email notifications in the appraisal workflow are configurable per +appraisal. + +By default, email notifications are enabled. When the appraisal is +confirmed, an email is sent to the employee and the assigned managers. +Similarly, when the appraisal is marked as Done, completion emails are +sent. + +If the **Send email notifications** option is disabled on the appraisal +record, no automatic emails will be sent during confirmation or +completion. All other workflow actions, such as state changes and +activity creation, remain unchanged. + +This allows disabling notifications for specific appraisals without +affecting the standard behavior for others. + - Tip Modifications are not possible once the appraisal is marked as done. diff --git a/hr_appraisal_oca/i18n/es.po b/hr_appraisal_oca/i18n/es.po index 94d769aa3ef..7acc3e3811d 100644 --- a/hr_appraisal_oca/i18n/es.po +++ b/hr_appraisal_oca/i18n/es.po @@ -777,6 +777,11 @@ msgstr "" msgid "If checked, some messages have a delivery error." msgstr "Si se encuentra seleccionado, algunos mensajes tienen error de envío." +#. module: hr_appraisal_oca +#: model:ir.model.fields,help:hr_appraisal_oca.field_hr_appraisal__send_email_notifications +msgid "If unchecked, no automatic emails will be sent in the evaluation flow." +msgstr "Si esta casilla no está marcada, no se enviarán correos electrónicos automáticos durante el proceso de valoración." + #. module: hr_appraisal_oca #: model:ir.model.fields,field_description:hr_appraisal_oca.field_hr_appraisal_template__is_default msgid "Is Default" @@ -1050,6 +1055,11 @@ msgstr "Enviar" msgid "Send by email" msgstr "Enviar por correo electrónico" +#. module: hr_appraisal_oca +#: model:ir.model.fields,field_description:hr_appraisal_oca.field_hr_appraisal__send_email_notifications +msgid "Send email notifications" +msgstr "Enviar notificaciones" + #. module: hr_appraisal_oca #: model:ir.model,name:hr_appraisal_oca.model_send_email_with_template msgid "Sending Email with Template" diff --git a/hr_appraisal_oca/i18n/hr_appraisal_oca.pot b/hr_appraisal_oca/i18n/hr_appraisal_oca.pot index 67924dc2239..8d6d3856be9 100644 --- a/hr_appraisal_oca/i18n/hr_appraisal_oca.pot +++ b/hr_appraisal_oca/i18n/hr_appraisal_oca.pot @@ -611,6 +611,11 @@ msgstr "" msgid "If checked, some messages have a delivery error." msgstr "" +#. module: hr_appraisal_oca +#: model:ir.model.fields,help:hr_appraisal_oca.field_hr_appraisal__send_email_notifications +msgid "If unchecked, no automatic emails will be sent in the evaluation flow." +msgstr "" + #. module: hr_appraisal_oca #: model:ir.model.fields,field_description:hr_appraisal_oca.field_hr_appraisal_template__is_default msgid "Is Default" @@ -879,6 +884,11 @@ msgstr "" msgid "Send by email" msgstr "" +#. module: hr_appraisal_oca +#: model:ir.model.fields,field_description:hr_appraisal_oca.field_hr_appraisal__send_email_notifications +msgid "Send email notifications" +msgstr "" + #. module: hr_appraisal_oca #: model:ir.model,name:hr_appraisal_oca.model_send_email_with_template msgid "Sending Email with Template" diff --git a/hr_appraisal_oca/models/hr_appraisal.py b/hr_appraisal_oca/models/hr_appraisal.py index c91a06fb26c..824d4b13773 100644 --- a/hr_appraisal_oca/models/hr_appraisal.py +++ b/hr_appraisal_oca/models/hr_appraisal.py @@ -101,6 +101,11 @@ class HrAppraisal(models.Model): ) tag_ids = fields.Many2many("hr.appraisal.tag", string="Tags") active = fields.Boolean(default=True) + send_email_notifications = fields.Boolean( + string="Send email notifications", + default=True, + help="If unchecked, no automatic emails will be sent in the evaluation flow.", + ) @api.model def default_get(self, fields_list): @@ -142,6 +147,14 @@ def default_get(self, fields_list): ) return res + def _can_send_appraisal_email(self): + self.ensure_one() + # Permite sobreescribir por contexto en acciones puntuales: + # context['send_email_notifications'] = True/False + return self.env.context.get( + "send_email_notifications", self.send_email_notifications + ) + @api.model def _default_employee_id(self): """ @@ -354,6 +367,9 @@ def action_back(self): self.state = "1_new" def _send_email(self, recipient_users, template, email): + # Si está desactivado, no enviar correo (pero el resto del flujo sigue) + if not self._can_send_appraisal_email(): + return if not email or not recipient_users: return ctx = {"recipient_users": recipient_users} diff --git a/hr_appraisal_oca/readme/USAGE.md b/hr_appraisal_oca/readme/USAGE.md index 4e9535da919..79c24f9fce2 100644 --- a/hr_appraisal_oca/readme/USAGE.md +++ b/hr_appraisal_oca/readme/USAGE.md @@ -85,6 +85,19 @@ To restore an appraisal, open it (with the Archived filter active) and click Res Archiving does not delete the record; you can archive or restore appraisals at any time. +8\. Email notifications in the appraisal workflow are configurable per appraisal. + +By default, email notifications are enabled. When the appraisal is confirmed, +an email is sent to the employee and the assigned managers. Similarly, when +the appraisal is marked as Done, completion emails are sent. + +If the **Send email notifications** option is disabled on the appraisal record, +no automatic emails will be sent during confirmation or completion. All other +workflow actions, such as state changes and activity creation, remain unchanged. + +This allows disabling notifications for specific appraisals without affecting +the standard behavior for others. + - Tip Modifications are not possible once the appraisal is marked as done. diff --git a/hr_appraisal_oca/static/description/index.html b/hr_appraisal_oca/static/description/index.html index c1819ed2b53..13a76974a00 100644 --- a/hr_appraisal_oca/static/description/index.html +++ b/hr_appraisal_oca/static/description/index.html @@ -3,7 +3,7 @@ -README.rst +Appraisal Oca -
+
+

Appraisal Oca

- - -Odoo Community Association - -
-

Appraisal Oca

-

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

+

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

This module helps maintain the employee motivation process through periodic performance appraisals.

Managers can evaluate employee performance and enable employees to @@ -394,7 +389,7 @@

Appraisal Oca

-

Usage

+

Usage

To create a new appraisal for an employee, first navigate to the main Appraisals dashboard by opening the Appraisals app. The Appraisals dashboard is the default view.

@@ -474,6 +469,18 @@

Usage

click Restore.

Archiving does not delete the record; you can archive or restore appraisals at any time.

+

8. Email notifications in the appraisal workflow are configurable per +appraisal.

+

By default, email notifications are enabled. When the appraisal is +confirmed, an email is sent to the employee and the assigned managers. +Similarly, when the appraisal is marked as Done, completion emails are +sent.

+

If the Send email notifications option is disabled on the appraisal +record, no automatic emails will be sent during confirmation or +completion. All other workflow actions, such as state changes and +activity creation, remain unchanged.

+

This allows disabling notifications for specific appraisals without +affecting the standard behavior for others.

  • Tip
@@ -485,7 +492,7 @@

Usage

button again.

-

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 @@ -493,15 +500,15 @@

Bug Tracker

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

-

Credits

+

Credits

-

Authors

+

Authors

  • Fundación Esment
-

Contributors

+

Contributors

-

Maintainers

+

Maintainers

This module is maintained by the OCA.

Odoo Community Association @@ -530,6 +537,5 @@

Maintainers

-
diff --git a/hr_appraisal_oca/tests/test_hr_appraisal.py b/hr_appraisal_oca/tests/test_hr_appraisal.py index 837d29f45f8..6e30b087c24 100644 --- a/hr_appraisal_oca/tests/test_hr_appraisal.py +++ b/hr_appraisal_oca/tests/test_hr_appraisal.py @@ -1,6 +1,8 @@ # Copyright 2025 Fundación Esment - Estefanía Bauzá Illán # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from unittest.mock import patch + from markupsafe import Markup from odoo.tests import new_test_user @@ -118,3 +120,47 @@ def test_default_template_assigned(self): self.appraisal.manager_feedback, Markup(self.template.appraisal_manager_feedback_template), ) + + def test_action_confirm_sends_notifications_when_enabled(self): + appraisal = self.appraisal.with_user(self.user_manager) + appraisal.write({"send_email_notifications": True}) + with patch.object( + type(self.env["send.email.with.template"]), + "send_email_with_template", + autospec=True, + ) as mocked_send: + appraisal.action_confirm() + self.assertEqual(mocked_send.call_count, 2) + + def test_action_confirm_does_not_send_notifications_when_disabled(self): + appraisal = self.appraisal.with_user(self.user_manager) + appraisal.write({"send_email_notifications": False}) + with patch.object( + type(self.env["send.email.with.template"]), + "send_email_with_template", + autospec=True, + ) as mocked_send: + appraisal.action_confirm() + self.assertEqual(mocked_send.call_count, 0) + + def test_action_done_does_not_send_notifications_when_disabled(self): + appraisal = self.appraisal.with_user(self.user_manager) + appraisal.write({"send_email_notifications": False}) + with patch.object( + type(self.env["send.email.with.template"]), + "send_email_with_template", + autospec=True, + ) as mocked_send: + appraisal.action_done() + self.assertEqual(mocked_send.call_count, 0) + + def test_context_can_override_send_email_notifications(self): + appraisal = self.appraisal.with_user(self.user_manager) + appraisal.write({"send_email_notifications": False}) + with patch.object( + type(self.env["send.email.with.template"]), + "send_email_with_template", + autospec=True, + ) as mocked_send: + appraisal.with_context(send_email_notifications=True).action_confirm() + self.assertEqual(mocked_send.call_count, 2) diff --git a/hr_appraisal_oca/views/hr_appraisal_form_view.xml b/hr_appraisal_oca/views/hr_appraisal_form_view.xml index f5730de7b87..368590b1481 100644 --- a/hr_appraisal_oca/views/hr_appraisal_form_view.xml +++ b/hr_appraisal_oca/views/hr_appraisal_form_view.xml @@ -102,6 +102,12 @@ +