Skip to content
Snippets Groups Projects
Commit 9419d171 authored by Lucas Lefèvre's avatar Lucas Lefèvre
Browse files

[FIX] hr: Allow to access employee profile

The `private_email`, `last_check_in` and `last_check_in`
fields were added by e9d98982 to the
profile view but not in `SELF_READABLE_FIELDS`.
A simple user was therefore not able to read the field and
access his profile.

To avoid any similar oversight in the future, a test is added
to ensure a simple user is able to read all fields in
the profile view.
parent 58c14d0f
No related branches found
No related tags found
No related merge requests found
......@@ -95,6 +95,7 @@ class User(models.Model):
'identification_id',
'is_address_home_a_company',
'job_title',
'private_email',
'km_home_work',
'marital',
'mobile_phone',
......
......@@ -4,9 +4,25 @@
from collections import OrderedDict
from odoo.addons.hr.tests.common import TestHrCommon
from odoo.tests import new_test_user
from odoo.tests import new_test_user, tagged
from odoo.exceptions import AccessError
@tagged('post_install', '-at_install')
class TestSelfAccessProfile(TestHrCommon):
def test_access_my_profile(self):
""" A simple user should be able to read all fields in his profile """
james = new_test_user(self.env, login='hel', groups='base.group_user', name='Simple employee', email='ric@example.com')
james = james.with_user(james)
self.env['hr.employee'].create({
'name': 'James',
'user_id': james.id,
})
view = self.env.ref('hr.res_users_view_form_profile')
view_infos = james.fields_view_get(view_id=view.id)
fields = view_infos['fields'].keys()
james.read(fields)
class TestSelfAccessRights(TestHrCommon):
......
......@@ -22,6 +22,8 @@ class User(models.Model):
'hours_last_month',
'hours_last_month_display',
'attendance_state',
'last_check_in',
'last_check_out'
]
super(User, self).__init__(pool, cr)
# duplicate list to avoid modifying the original reference
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment