Search code examples
pythonodoo-9

How to add group based filter for many2one field in odoo


In my custom module i have two groups user and manager. Based on the group there are mutliple users. I have two may2one field both referring to res.users. In one field i need to show users associated with user group and in one field i need to show users associated with manager group. How can i filter the many2one fields


Solution

  • Use domain in field declaration:

    myfield = fields.Many2one("res.partner", domain=[('mygroup', '=', 'yourgroup')])