Odoo Help


How to filter 2 relational fields selection content?

on 8/5/15, 9:59 AM 703 views

I need to filter a content of 2 relational fields 

My case is I have Person that have enemy list and only one best friend.

It is required that one person can not be a friend and an enemy of another.

So I need if person is in the enemy list to not be shown in the best friend selection and

the opposite if a person is best friend to not be shown in enemy selection

Also that a person can not be best friend and enemy to it self.

example code:


# -*- coding: utf-8 -*-

from openerp import models, fields, api

class person(models.Model):

    _name = 'Person'

    _description = 'Person is a human being with a name’

    name = fields.Char('Name')

    enemyRecordset = fields.Many2many(comodel_name='person',



        column2='person2_id', string='Enemy')

    bestFriendRecordset = fields.Many2one('person', 'Best Friend’)








                        <group name="groupRight">


                                <!-- Must not contain person it self and best friends -->

                                <field name="enemyRecordset" />



                        <group> name="groupLeft">


                                <!-- Must not contain person it self and enemies -->

                                <field name="bestFriendRecordset" />









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: 8/5/15, 9:59 AM
Seen: 703 times
Last updated: 8/5/15, 9:59 AM