Book Image

Odoo Development Cookbook

By : Holger Brunn, Alexandre Fayolle, Daniel Reis
Book Image

Odoo Development Cookbook

By: Holger Brunn, Alexandre Fayolle, Daniel Reis

Overview of this book

Odoo is a full-featured open source ERP with a focus on extensibility. The flexibility and sustainability of open source is also a key selling point of Odoo. It is built on a powerful framework for rapid application development, both for back-end applications and front-end websites. The book starts by covering Odoo installation and administration, and provides a gentle introduction to application development. It then dives deep into several of the areas that an experienced developer will need to use. You’ll learn implement business logic, adapt the UI, and extend existing features.
Table of Contents (23 chapters)
Odoo Development Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Combining recordsets


Sometimes, you will find that you have obtained recordsets which are not exactly what you need. This recipe shows various ways of combining them.

Getting ready

To use this recipe, you need to have two or more recordsets for the same model.

How to do it…

Here is the way to achieve common operations on recordsets:

  1. To merge two recordsets into one while preserving their order, use the following operation:

    result = recordset1 + recordset2
  2. To merge two recordsets into one ensuring that there are no duplicates in the result, use the following operation:

    result = recordset1 | recordset2
  3. To find the records that are common to two recordsets, use the following operation:

    result = recordset1 & recordset2

How it works…

The class for recordsets implements various Python operator redefinitions, which are used here. Here is a summary table of the most useful Python operators that can be used on recordsets:

Operator

Action performed

R1 + R2

This returns a new recordset containing the...