Subject : Set read-only fields for different groups users.

Related : Access rights


In access right we can do read-only fields for particular users in group.

For that,

We have to take one computational field in model.

Example: I just want to set fields read-only if the current user is Portal group user.

Following is a method for computational field, which will get current user group and set string according to their role as you want to validate in xml file.

In .py File 


def _compute_user_group(self):

for rec in self:

groups_id = self.env[‘res.users’].browse(self._uid)

# For admin user

if == 1:


# For Project Manager

elif groups_id.has_group(‘project.group_project_manager’):


# For Project User

elif groups_id.has_group(‘project.group_project_user’):


# For Portal user

elif groups_id.has_group(‘base.group_portal’) :

rec.user_group = ‘portal’

# Field

user_group = fields.Char(compute=’_compute_user_group’,string=’User Group’)


In xml file,

I have done using inheritance concept.

<!– Inherit Project Issues of  –>

<record id=”project_issue_view_form_inherit” model=”ir.ui.view”>

<field name=”name”>Project Issue Tracker Form</field>

<field name=”model”>project.issue</field>

<field name=”inherit_id” ref=”project_issue.project_issue_form_view”/>

<field name=”arch” type=”xml”>


<xpath expr=”//form/sheet/group/group[1]” position=”inside”>

<field name=”user_group” invisible=”1″/>

<field name=”user_id”  attrs = “{‘readonly’:[(‘user_group’,’in’,[‘portal’])]}”/>

<field name=”partner_id”  attrs = “{‘readonly’:[(‘user_group’,’in’,[‘portal’])]}”/>

<field name=”deadline_date” attrs=”{‘readonly’:[(‘user_group’,’in’,[‘portal’])]}”/>




Streamline your Business process with Nevpro’s ERP Software for small medium and large enterprises.