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
22 changes: 17 additions & 5 deletions hr_appraisal_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

=============
Appraisal Oca
=============
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down
10 changes: 10 additions & 0 deletions hr_appraisal_oca/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
10 changes: 10 additions & 0 deletions hr_appraisal_oca/i18n/hr_appraisal_oca.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
16 changes: 16 additions & 0 deletions hr_appraisal_oca/models/hr_appraisal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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}
Expand Down
13 changes: 13 additions & 0 deletions hr_appraisal_oca/readme/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
38 changes: 22 additions & 16 deletions hr_appraisal_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>Appraisal Oca</title>
<style type="text/css">

/*
Expand Down Expand Up @@ -360,21 +360,16 @@
</style>
</head>
<body>
<div class="document">
<div class="document" id="appraisal-oca">
<h1 class="title">Appraisal 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="appraisal-oca">
<h1>Appraisal Oca</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:3f63ea6cad290f36bf1d6dee541e8d31e469d1d759f25df21339cf4c024fa59c
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/hr/tree/18.0/hr_appraisal_oca"><img alt="OCA/hr" src="https://img.shields.io/badge/github-OCA%2Fhr-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/hr-18-0/hr-18-0-hr_appraisal_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/hr&amp;target_branch=18.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/hr/tree/18.0/hr_appraisal_oca"><img alt="OCA/hr" src="https://img.shields.io/badge/github-OCA%2Fhr-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/hr-18-0/hr-18-0-hr_appraisal_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/hr&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module helps maintain the employee motivation process through
periodic performance appraisals.</p>
<p>Managers can evaluate employee performance and enable employees to
Expand All @@ -394,7 +389,7 @@ <h1>Appraisal Oca</h1>
</ul>
</div>
<div class="section" id="usage">
<h2><a class="toc-backref" href="#toc-entry-1">Usage</a></h2>
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
<p>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.</p>
Expand Down Expand Up @@ -474,6 +469,18 @@ <h2><a class="toc-backref" href="#toc-entry-1">Usage</a></h2>
click Restore.</p>
<p>Archiving does not delete the record; you can archive or restore
appraisals at any time.</p>
<p>8. Email notifications in the appraisal workflow are configurable per
appraisal.</p>
<p>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.</p>
<p>If the <strong>Send email notifications</strong> 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.</p>
<p>This allows disabling notifications for specific appraisals without
affecting the standard behavior for others.</p>
<ul class="simple">
<li>Tip</li>
</ul>
Expand All @@ -485,23 +492,23 @@ <h2><a class="toc-backref" href="#toc-entry-1">Usage</a></h2>
button again.</p>
</div>
<div class="section" id="bug-tracker">
<h2><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h2>
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/hr/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/hr/issues/new?body=module:%20hr_appraisal_oca%0Aversion:%2018.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-3">Credits</a></h2>
<h1><a class="toc-backref" href="#toc-entry-3">Credits</a></h1>
<div class="section" id="authors">
<h3><a class="toc-backref" href="#toc-entry-4">Authors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
<ul class="simple">
<li>Fundación Esment</li>
</ul>
</div>
<div class="section" id="contributors">
<h3><a class="toc-backref" href="#toc-entry-5">Contributors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<ul class="simple">
<li><a class="reference external" href="https://esment.org/">Fundación Esment</a>:<ul>
<li>Estefanía Bauzá</li>
Expand All @@ -515,7 +522,7 @@ <h3><a class="toc-backref" href="#toc-entry-5">Contributors</a></h3>
</ul>
</div>
<div class="section" id="maintainers">
<h3><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h3>
<h2><a class="toc-backref" href="#toc-entry-6">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 @@ -530,6 +537,5 @@ <h3><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h3>
</div>
</div>
</div>
</div>
</body>
</html>
46 changes: 46 additions & 0 deletions hr_appraisal_oca/tests/test_hr_appraisal.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
6 changes: 6 additions & 0 deletions hr_appraisal_oca/views/hr_appraisal_form_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@
<field name="state" invisible="1" />
<field name="id" invisible="1" />
<field name="company_id" invisible="1" />
<field
name="send_email_notifications"
widget="boolean_toggle"
invisible="employee_user_id == uid"
readonly="state == '3_done'"
/>
<field name="employee_domain_ids" invisible="1" />
<field
name="company_id"
Expand Down
Loading