On the relation: Attendee –>(many2one) -> Session –> (many2one) -> Course

How to find attendees which belongs to a Course? Ie, performing search and grouping on attendee list which attend a Course.

The solution is to add a new column on attendee.py, with type of related and define the relation to Course model:

 

‘course_id’: fields.related(

‘session_id’,

‘course_id’,

type=”many2one”,

relation=”my_module.course”,

string=”Course”,

store=True)

 

The course_id column can be used for filter and grouping as a normal field, example:

 

<search string=”Search Attendees”>

<field name=”course_id”/>

<field name=”name”/>

<field name=”session_id”/>

<field name=”partner_id”/>

<separator/>

<group expand=”1″ string=”Group By…”>

<filter string=”Partner” icon=”terp-personal” domain=”[]” context=”{‘group_by’:’partner_id’}”/>

<filter string=”Session” icon=”terp-personal” domain=”[]” context=”{‘group_by’:’session_id’}”/>

<filter string=”Course” icon=”terp-personal” domain=”[]” context=”{‘group_by’:’course_id’}”/>

</group>

</search>

 

 

Searching for multi-level relation on OpenERP 7.0