Odoo Help

Welcome!

This community 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.

0

Domain filter syntax

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

Hi , Please help i new in odoo.


Please help me fix this syntax of domain.

('create_uid','in',[('po_users_rel','=',uid])


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)


0
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)]


EDITED:

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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