Odoo Help


Make a field modifiable only by users/employes with a job_id specifique

on 10/19/16, 4:56 AM 491 views


all is in the title, how to make a field ediable only for a current user with a specifique job_id (user attached with a employe entry)

thx in advance


Nilmar Shereef

--Nilmar Shereef--
--Nilmar Shereef--

Python Developer. Odoo Techno Functional Consultant.

Nilmar Shereef
On 11/1/16, 2:19 AM

I solved this problem by adding a python function. So please create another boolean field like get_user = fields.Boolean(string='User', compute=_check_responsible,  invisible=True) . Then give the functional description inside _check_responsible. For example you can check the current user is involved a group like this: flag_hr_manager = self.env['res.users'].has_group('base.group_hr_manager'). If flag_hr_manager fields gives TRUE, then the current user is involved that group. You can also check any other custom checking inside this function. Don't forget to assign the True/False at the end of this function.

Now, you can check user is eligible to edit the desired field using attrs.
for example: <field name="your_field" attrs="{'readonly':[('get_user','!=',True)]}"/>
in your xml file
or, editing in fields_view_get is another option
Hope this will help you. Thankyou

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 10/19/16, 4:56 AM
Seen: 491 times
Last updated: 11/1/16, 2:19 AM