From b227b16ac10e6e29149fda4c47d5089ac757676f Mon Sep 17 00:00:00 2001 From: Joan Sisquella Date: Mon, 10 Jul 2023 10:40:46 +0200 Subject: [PATCH] [FIX] hr_employee_birthay_mail: res_users configurable --- hr_employee_birthday_mail/README.rst | 2 +- hr_employee_birthday_mail/__manifest__.py | 7 ++++- hr_employee_birthday_mail/models/__init__.py | 1 + .../models/hr_employee.py | 2 ++ hr_employee_birthday_mail/models/res_user.py | 31 +++++++++++++++++++ .../static/description/index.html | 2 +- .../views/res_user_views.xml | 20 ++++++++++++ 7 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 hr_employee_birthday_mail/models/res_user.py create mode 100644 hr_employee_birthday_mail/views/res_user_views.xml diff --git a/hr_employee_birthday_mail/README.rst b/hr_employee_birthday_mail/README.rst index 292e735c8fe1..a6f10a332d24 100644 --- a/hr_employee_birthday_mail/README.rst +++ b/hr_employee_birthday_mail/README.rst @@ -7,7 +7,7 @@ HR Employee Birthday Mail !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:78b7ea0d8f32fb8ad80ea3e33eb8a629c4e28541d987bc8899134009bc9aa659 + !! source digest: sha256:0459daf58a691fcbcf0b1c2154fad1cfab0d7c402279f32dc055cd36abc6cd8f !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png diff --git a/hr_employee_birthday_mail/__manifest__.py b/hr_employee_birthday_mail/__manifest__.py index d39e0563452a..7fd0d054f554 100644 --- a/hr_employee_birthday_mail/__manifest__.py +++ b/hr_employee_birthday_mail/__manifest__.py @@ -9,7 +9,12 @@ "author": "ForgeFlow, Odoo Community Association (OCA)", "website": "https://github.com/OCA/hr", "depends": ["hr", "mail"], - "data": ["data/data.xml", "data/ir_cron.xml", "views/hr_employee_views.xml"], + "data": [ + "data/data.xml", + "data/ir_cron.xml", + "views/hr_employee_views.xml", + "views/res_user_views.xml", + ], "installable": True, "application": False, "auto_install": False, diff --git a/hr_employee_birthday_mail/models/__init__.py b/hr_employee_birthday_mail/models/__init__.py index e11a62f98ca0..529f9e93739f 100644 --- a/hr_employee_birthday_mail/models/__init__.py +++ b/hr_employee_birthday_mail/models/__init__.py @@ -1 +1,2 @@ from . import hr_employee +from . import res_user diff --git a/hr_employee_birthday_mail/models/hr_employee.py b/hr_employee_birthday_mail/models/hr_employee.py index 543451cc8b9a..64873d2635ee 100644 --- a/hr_employee_birthday_mail/models/hr_employee.py +++ b/hr_employee_birthday_mail/models/hr_employee.py @@ -13,10 +13,12 @@ class HrEmployee(models.Model): default=False, help="Check this box if you want to allow birthday wishes from our company " "and allow the others to be notified of your birthday.", + groups="hr.group_hr_user", ) notify_others_birthday = fields.Boolean( default=False, help="Check this box if you want to be notified about other coworkers' birthdays.", + groups="hr.group_hr_user", ) @api.model diff --git a/hr_employee_birthday_mail/models/res_user.py b/hr_employee_birthday_mail/models/res_user.py new file mode 100644 index 000000000000..85c9747a0668 --- /dev/null +++ b/hr_employee_birthday_mail/models/res_user.py @@ -0,0 +1,31 @@ +# Copyright 2023 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class User(models.Model): + _inherit = ["res.users"] + + allow_birthday_wishes = fields.Boolean( + related="employee_id.allow_birthday_wishes", readonly=False, related_sudo=False + ) + notify_others_birthday = fields.Boolean( + related="employee_id.notify_others_birthday", readonly=False, related_sudo=False + ) + + def __init__(self, pool, cr): + """Override of __init__ to add access rights. + Access rights are disabled by default, but allowed + on some specific fields defined in self.SELF_{READ/WRITE}ABLE_FIELDS. + """ + super(User, self).__init__(pool, cr) + # duplicate list to avoid modifying the original reference + type(self).SELF_READABLE_FIELDS = type(self).SELF_READABLE_FIELDS + [ + "allow_birthday_wishes", + "notify_others_birthday", + ] + type(self).SELF_WRITEABLE_FIELDS = type(self).SELF_WRITEABLE_FIELDS + [ + "allow_birthday_wishes", + "notify_others_birthday", + ] diff --git a/hr_employee_birthday_mail/static/description/index.html b/hr_employee_birthday_mail/static/description/index.html index b02ec02afbb3..d582558ab21b 100644 --- a/hr_employee_birthday_mail/static/description/index.html +++ b/hr_employee_birthday_mail/static/description/index.html @@ -367,7 +367,7 @@

HR Employee Birthday Mail

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:78b7ea0d8f32fb8ad80ea3e33eb8a629c4e28541d987bc8899134009bc9aa659 +!! source digest: sha256:0459daf58a691fcbcf0b1c2154fad1cfab0d7c402279f32dc055cd36abc6cd8f !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

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

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.

diff --git a/hr_employee_birthday_mail/views/res_user_views.xml b/hr_employee_birthday_mail/views/res_user_views.xml new file mode 100644 index 000000000000..39f7b5ef3298 --- /dev/null +++ b/hr_employee_birthday_mail/views/res_user_views.xml @@ -0,0 +1,20 @@ + + + + res.users.birthday.mail.inherit + res.users + + + + + + + + +