I think you need something like : You have created one many2one field for Groups. In which, you want to list number of groups only that assign with current login user. Right? If yes, then I can suggest one way to you
First, you need to make one function field like group_ids in your current model. Then you have to set all groups of current login user in that field. Then you can use that field in domain.
Here is the example for function field (.py file)
def _get_user_groups(self,cr,uid,ids,fields,arg,context={}):
res = dict.fromkeys(ids,[])
user = self.pool.get('res.users').browse(cr,uid,uid)
for partner in self.browse(cr,uid,ids):
user_group_ids = map(int,user.groups_id)
res[partner.id] = user_group_ids
return res
_columns={
'group_ids':fields.function(_get_user_groups,type='many2many',relation='res.groups',
string='Groups'),
}
def _get_default_user_groups(self,cr,uid,context={}):
user = self.pool.get('res.users').browse(cr,uid,uid)
user_group_ids = map(int,user.groups_id)
return user_group_ids
_defaults={
'group_ids':_get_default_user_groups,
}
You must use _defaults because function field value set after record is save. So, at a time to create new record, if you don't use _defaults for group_ids field, there will not any group is set in this field.
In xml file you need to add field like :
<field name="group_ids" invisible="1" />
<field name="group_id" string="Group" domain="[('id','in',group_ids[0][2])]">
check this: https://learnopenerp.blogspot.com/2017/10/how-to-check-login-user-group-in-odoo.html