Hey Man Dont use the Functional field on the record rules , they wont help you, because record use applies to the record(Direct from the Database) And the functional fields are calculated when the records are shown, so they wont help you in achieveing what you are looking for.Instead try this:
_columns={
'g1_group':fields.many2one('res.groups', string='G1 Group'),
'g2_group':fields.many2one('res.groups', string='G2 Group'),
}
def _g1_group(self, cr, uid, context=None):
all_groups=self.pool.get('res.groups')
all_users =self.pool.get('res.users')
g1_ids = all_groups.search(cr,uid,[('name','=','G1 Group')])
if not g1_ids: return False
if not g1_ids in all_users.browse(cr, uid, uid,context=context).groups_id:
return False
edit_group = all_groups.browse(cr, uid, g1_ids[0],context=context).id
return edit_group
def _g2_group(self, cr, uid, context=None):
all_groups=self.pool.get('res.groups')
all_users =self.pool.get('res.users')
g2_ids = all_groups.search(cr,uid,[('name','=','G2 Group')])
if not g2_ids: return False
if not g2_ids in all_users.browse(cr, uid, uid,context=context).groups_id:
return False
edit_group = all_groups.browse(cr, uid, g2_ids[0],context=context).id
return edit_group
_defaults = {
'g1_group':lambda self, cr, uid, context:self._g1_group( cr, uid, context=None)
'g2_group':lambda self, cr, uid, context:self._g2_group( cr, uid, context=None)
}
In the Record rule check Whether the entered user is in the group so that he can see the records.
[('g1_group','in',[g.id for g in user.groups_id])]
to check for the g2 group:
[('g2_group','in',[g.id for g in user.groups_id])]
I hope this may help you.