Hello everybody,
My Goal is to make field readonly based on assigned group to logged in user.
I want to make few field readonly based on assgined groups to logged in user.
I have tried these two methods to set attrs for perticular field.
For Eg, I want to make readonly field on SO form.
We have user_id field inside SO, so i have applied like this on xml part.
This doesn't work!
<field name="field name" position="attributes">
<attribute name="attrs">{'readonly':[('group_name','in',[group.id for group in user_id.groups_id])]}</attribute>
</field>
This is too does not work!
<field name="field name" position="attributes">-->
<attribute name="attrs">{'readonly':[('group_name','in',[group.id for group in user.groups_id])]}</attribute>
</field>
Even we have user_id field inside the model, its give user_id field is not defiend. how?
I have tried to apply the same thing based on_change method too!
Is it possible to set attrs on field using onchange method?
Anyboday has idea about this?
Thanks in advance!
Regards,
Anil.
Yes you can apply attributes [visible/invisible, readonly] based on different users. The idea is to create a Boolean field and make this field True/False on onchange of some field, and later use that boolean field in attr.
Have a look into code: http://learnopenerp.blogspot.com/2016/10/how-to-visible-and-invisible-fields-in.html
Hope its helpful for you and others.
Thanks