2
votes

I am trying to filter the records based on their group id. I have written a domain filter in menu action like this

[('pending_approver','in',[g.id for g in user.groups_id])]

pending_approver is a Many2one field with res.groups

Have a look on this for more clarification.

def _default_approver(self):
    obj = self.env['approval_heirarchy.approval_rules'].search([('id', '=', 1)], limit=1)
    if obj.x_approver_ids:
        val = obj.x_approver_ids[0].x_user_ids
        return obj.x_approver_ids[0].x_user_ids.id

pending_approver = fields.Many2one('res.groups', string="Pending Approver", readonly=True,default=_default_approver)

Whenever run the application prompt an Odoo Client Error:

Uncaught Error: Expected "]", got "(name)" 

I've searched a lot but didn't find any solution. Any help will be a great regard for me. Thanks in Advance!

1
Can you use [('pending_approver','in',user.groups_id.ids)] - travisw
If you show full stack trace is better and where did you put the domain in the action? - Charif DZ

1 Answers

2
votes
if self.user_has_groups('sales_team.group_sale_manager') is True:
    code part...

this code may help you.....any queries please free to ask