You can use fields_view_get method for that. In this method you need to check the current user's group and based on that you can make the field readonly / editable.
1st Option:
Try following code:
from lxml import etree
@api.model
def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):
result = super(AccountInvoice, self).fields_view_get(view_id, view_type, toolbar=toolbar, submenu=submenu)
doc = etree.XML(result['arch'])
if self._uid != SUPERUSER_ID and (not user.has_group('module_name.your_group_id'):
if doc.xpath("//field[@name='field_name']"):
node = doc.xpath("//field[@name='field_name']")[0]
modifiers = json.loads(node.get("modifiers", '{}'))
modifiers.update({'readonly': True})
node.set("modifiers", json.dumps(modifiers))
result['arch'] = etree.tostring(doc)
return result
2nd Option:
Yes, you can do it by compute method as well. Create a boolean field with compute and make it True or False based on the user' group (check by user.has_group method).
Now, use boolean field in attrs to make the field readonly.
Your compute field must not be store=True and your compute method must use api.multi only and not api.depends. Because we want to check the group of the logged in user each time the record is opened.