Skip to content

Commit b227b16

Browse files
[FIX] hr_employee_birthay_mail: res_users configurable
1 parent 11a3769 commit b227b16

File tree

7 files changed

+62
-3
lines changed

7 files changed

+62
-3
lines changed

hr_employee_birthday_mail/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ HR Employee Birthday Mail
77
!! This file is generated by oca-gen-addon-readme !!
88
!! changes will be overwritten. !!
99
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10-
!! source digest: sha256:78b7ea0d8f32fb8ad80ea3e33eb8a629c4e28541d987bc8899134009bc9aa659
10+
!! source digest: sha256:0459daf58a691fcbcf0b1c2154fad1cfab0d7c402279f32dc055cd36abc6cd8f
1111
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1212
1313
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png

hr_employee_birthday_mail/__manifest__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99
"author": "ForgeFlow, Odoo Community Association (OCA)",
1010
"website": "https://github.com/OCA/hr",
1111
"depends": ["hr", "mail"],
12-
"data": ["data/data.xml", "data/ir_cron.xml", "views/hr_employee_views.xml"],
12+
"data": [
13+
"data/data.xml",
14+
"data/ir_cron.xml",
15+
"views/hr_employee_views.xml",
16+
"views/res_user_views.xml",
17+
],
1318
"installable": True,
1419
"application": False,
1520
"auto_install": False,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
from . import hr_employee
2+
from . import res_user

hr_employee_birthday_mail/models/hr_employee.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ class HrEmployee(models.Model):
1313
default=False,
1414
help="Check this box if you want to allow birthday wishes from our company "
1515
"and allow the others to be notified of your birthday.",
16+
groups="hr.group_hr_user",
1617
)
1718
notify_others_birthday = fields.Boolean(
1819
default=False,
1920
help="Check this box if you want to be notified about other coworkers' birthdays.",
21+
groups="hr.group_hr_user",
2022
)
2123

2224
@api.model
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright 2023 ForgeFlow S.L. (https://www.forgeflow.com)
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
4+
from odoo import fields, models
5+
6+
7+
class User(models.Model):
8+
_inherit = ["res.users"]
9+
10+
allow_birthday_wishes = fields.Boolean(
11+
related="employee_id.allow_birthday_wishes", readonly=False, related_sudo=False
12+
)
13+
notify_others_birthday = fields.Boolean(
14+
related="employee_id.notify_others_birthday", readonly=False, related_sudo=False
15+
)
16+
17+
def __init__(self, pool, cr):
18+
"""Override of __init__ to add access rights.
19+
Access rights are disabled by default, but allowed
20+
on some specific fields defined in self.SELF_{READ/WRITE}ABLE_FIELDS.
21+
"""
22+
super(User, self).__init__(pool, cr)
23+
# duplicate list to avoid modifying the original reference
24+
type(self).SELF_READABLE_FIELDS = type(self).SELF_READABLE_FIELDS + [
25+
"allow_birthday_wishes",
26+
"notify_others_birthday",
27+
]
28+
type(self).SELF_WRITEABLE_FIELDS = type(self).SELF_WRITEABLE_FIELDS + [
29+
"allow_birthday_wishes",
30+
"notify_others_birthday",
31+
]

hr_employee_birthday_mail/static/description/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ <h1 class="title">HR Employee Birthday Mail</h1>
367367
!! This file is generated by oca-gen-addon-readme !!
368368
!! changes will be overwritten. !!
369369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370-
!! source digest: sha256:78b7ea0d8f32fb8ad80ea3e33eb8a629c4e28541d987bc8899134009bc9aa659
370+
!! source digest: sha256:0459daf58a691fcbcf0b1c2154fad1cfab0d7c402279f32dc055cd36abc6cd8f
371371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
372372
<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/14.0/hr_employee_birthday_mail"><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-14-0/hr-14-0-hr_employee_birthday_mail"><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=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
373373
<p>The module automates the process of sending out personalized birthday emails to the celebrating employee while also informing their coworkers about the special day. It encourages a culture of mutual respect, camaraderie, and celebration within the team.</p>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<odoo>
3+
<record id="res_users_birthday_mail_inherit" model="ir.ui.view">
4+
<field name="name">res.users.birthday.mail.inherit</field>
5+
<field name="model">res.users</field>
6+
<field name="inherit_id" ref="hr.res_users_view_form_profile" />
7+
<field name="arch" type="xml">
8+
<field name="birthday" position="after">
9+
<field
10+
name="allow_birthday_wishes"
11+
attrs="{'readonly': [('can_edit', '=', False)]}"
12+
/>
13+
<field
14+
name="notify_others_birthday"
15+
attrs="{'readonly': [('can_edit', '=', False)], 'invisible': [('allow_birthday_wishes', '=', False)]}"
16+
/>
17+
</field>
18+
</field>
19+
</record>
20+
</odoo>

0 commit comments

Comments
 (0)