O'Reilly logo

Odoo Development Cookbook by Daniel Reis, Alexandre Fayolle, Holger Brunn

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Traversing recordset relations

When working with a recordset of length 1, the various fields are available as record attributes. Relational attributes (One2many, Many2one, and Many2many) are also available with values that are recordsets too. When working with recordsets with more than one record, the attributes cannot be used.

This recipe shows how to use the mapped() method to traverse recordset relations; we will write two methods performing the following operations:

  • Retrieving the e-mails of all contacts of a single partner company passed as an argument
  • Retrieving the various companies to which some contact partners are related

Getting ready

We will be reusing the simplified Partner model shown in the Create new records recipe of this chapter. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required