From 3d0da8b7f78b7638af862d3bcda4387f6ffa792c 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 | 29 +++++++++++++++++++ .../views/res_user_views.xml | 20 +++++++++++++ 6 files changed, 59 insertions(+), 2 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 42052a4cd96..9f88a310cf4 100644 --- a/hr_employee_birthday_mail/README.rst +++ b/hr_employee_birthday_mail/README.rst @@ -2,7 +2,7 @@ HR Employee Birthday Mail ========================= -.. +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! diff --git a/hr_employee_birthday_mail/__manifest__.py b/hr_employee_birthday_mail/__manifest__.py index 974727a4a3b..4e226f01cd0 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 e11a62f98ca..529f9e93739 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 543451cc8b9..64873d2635e 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 00000000000..fbbe5b52dba --- /dev/null +++ b/hr_employee_birthday_mail/models/res_user.py @@ -0,0 +1,29 @@ +# 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 + ) + + @property + def SELF_READABLE_FIELDS(self): + return super().SELF_READABLE_FIELDS + [ + "allow_birthday_wishes", + "notify_others_birthday", + ] + + @property + def SELF_WRITEABLE_FIELDS(self): + return super().SELF_WRITEABLE_FIELDS + [ + "allow_birthday_wishes", + "notify_others_birthday", + ] 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 00000000000..39f7b5ef329 --- /dev/null +++ b/hr_employee_birthday_mail/views/res_user_views.xml @@ -0,0 +1,20 @@ + + + + res.users.birthday.mail.inherit + res.users + + + + + + + + +