Odoo Help

Welcome!

This community 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.

0

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

By
VodoO
on 10/19/16, 4:56 AM 126 views

Hi,


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

3

Nilmar Shereef

--Nilmar Shereef--
811
| 4 3 7
Calicut, India
--Nilmar Shereef--

Python Developer. Android Developer. .Net Developer

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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