-
-
Notifications
You must be signed in to change notification settings - Fork 672
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] hr_employee_birthay_mail: res_users configurable
- Loading branch information
1 parent
c913199
commit c6a8be9
Showing
7 changed files
with
62 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from . import hr_employee | ||
from . import res_user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
<record id="res_users_birthday_mail_inherit" model="ir.ui.view"> | ||
<field name="name">res.users.birthday.mail.inherit</field> | ||
<field name="model">res.users</field> | ||
<field name="inherit_id" ref="hr.res_users_view_form_profile" /> | ||
<field name="arch" type="xml"> | ||
<field name="birthday" position="after"> | ||
<field | ||
name="allow_birthday_wishes" | ||
attrs="{'readonly': [('can_edit', '=', False)]}" | ||
/> | ||
<field | ||
name="notify_others_birthday" | ||
attrs="{'readonly': [('can_edit', '=', False)], 'invisible': [('allow_birthday_wishes', '=', False)]}" | ||
/> | ||
</field> | ||
</field> | ||
</record> | ||
</odoo> |