Skip to Content
Menu
This question has been flagged
3 Replies
8979 Views

Hello to all, Does anyone knows how to solve this kind of situation? I have created security access on hr_contract. However, there are case where sometimes, the users cannot see some field. Here is the situation, on hr_employee i add field is_confidential and on hr_contract, if is_confidential (field on hr_employee) is checked, the user (let say HR I) cannot see employee's Wage and his Salary Structure but (HR II) can view this field including those confidential.


Any help is very much appreciated. Thank you.

Avatar
Discard
Best Answer

Hi Anirudh, try this :

In hr_employee:

'is_confidential': fields.boolean('Is Confidential')   (your field)

In hr_contract.py '

'is_confidential': fields.related('employee_id',is_confidential', type='boolean', relation='hr.employee', string="Is Confidential"),

In xml_view:
<field name="is_confidential" invisible="1" />
<field name="your field"  groups="user1_group" attrs="{'invisible': [(''is_confidential','!=','True')]}" />

Avatar
Discard
Author

In that case sir, both user1 and user2 cannot view the 'your_field' whenever 'is_confidential' is True. In my case, i want that only user1 can view employee's wage regardless if he or she is confidential but not on user2, beacuse if that employee is confidential then user2 cannot view it.

Best Answer

You use two fields: your_filed and your_field_related. XML in this case:

<field name="is_confidential" invisible="1" />

<field name="your_field" groups="user1_group" attrs="{'invisible': [(''is_confidential','!=','True')]}" />

<field name="your_field_related" groups="user2_group"/>

Avatar
Discard