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:
person.py
# -*- 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',
relation='person_rel',
column1='person1_id',
column2='person2_id', string='Enemy')
bestFriendRecordset = fields.Many2one('person', 'Best Friend’)
person_view.xml
<openerp>
<data>
<record>
<field>
<form>
<sheet>
<group name="groupRight">
<tree>
<!-- Must not contain person it self and best friends -->
<field name="enemyRecordset" />
</tree>
</group>
<group> name="groupLeft">
<form>
<!-- Must not contain person it self and enemies -->
<field name="bestFriendRecordset" />
</form>
</group>
</sheet>
</form>
</field>
</record>
</data>
</openerp>