Odoo Help


Domain filter syntax

Pichchanok Nuchpan
on 9/19/16, 11:49 PM 858 views

Hi , Please help i new in odoo.

Please help me fix this syntax of domain.


class po_permissions(models.Model):
    _name = 'purchase.order'
    _inherit = 'purchase.order'

    po_users_rel = fields.Many2many('res.users','user_rel_headsale','id','name',string='Manager(s)',relate='sale_set_headsale')

class sale_relation(models.Model):
    _name = 'res.users'
    _inherit = 'res.users'

    def _get_headsale_domain(self):
        return [('groups_id','=','Purchases / HeadSale'),('groups_id','=','Point of Sale / HeadSale')]

    sale_set_headsale = fields.Many2many('res.users','user_rel_headsale','id','name',string='Manager(s)', domain=_get_headsale_domain)

Juan Vicente Pascual
On 9/20/16, 2:37 AM

Try this,

def _get_headsale_domain(self):


                your_groups = []

                your_groups.append(self.env['res.users'].search([('name', '=', 'Purchases / HeadSale')]))

                your_groups.append(self.env['res.users'].search([('name', '=', 'Point of Sale / HeadSale')]))

                return [('groups_id','in', your_groups)]


You mean something like

('create_uid','in',[user.id for user in po_users_rel.id])

Kind regards.

thank for help.

but in now def _get_headsale_domain is okay.

i mean this [('create_uid','in',[('po_users_rel','=',uid)])] domain

Pichchanok Nuchpan
on 9/20/16, 2:42 AM

You mean something like

('create_uid','in',[user.id for user in po_users_rel.id])

yes, but i need to use this code in action domain (xml file)

Pichchanok Nuchpan
on 9/20/16, 4:12 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 9/19/16, 11:49 PM
Seen: 858 times
Last updated: 9/20/16, 2:37 AM