Book Image

Odoo 12 Development Essentials - Fourth Edition

By : Daniel Reis
Book Image

Odoo 12 Development Essentials - Fourth Edition

By: Daniel Reis

Overview of this book

Odoo is one of the best platforms for open source ERP and CRM. Its latest version, Odoo 12, brings with it new features and updates in Python packages to develop more customizable applications with additional cloud capabilities. The book begins by covering the development essentials for building business applications. You will start your journey by learning how to install and configure Odoo, and then transition from having no specific knowledge of Odoo to being ready for application development. You will develop your first Odoo application and understand topics such as models and views. Odoo 12 Development Essentials will also guide you in using server APIs to add business logic, helping you lay a solid foundation for advanced topics. As you progress through the chapters, you will be equipped to build and customize your applications and explore the new features in Odoo 12, such as cloud integration, to scale your business applications. You will get insights into building business logic and integrating various APIs into your application. By the end of the book, you will be able to build a business application from scratch by using the latest version of Odoo.
Table of Contents (22 chapters)
Title Page
Packt Upsell
Foreword
Contributors
Preface
Index

Accessing data on recordsets


Once we have a recordset, we want to inspect the data contained in it. In the following sections, we will explore how to access data in recordsets.

We can get field values for individual records, called singletons. Relational fields have special properties, and we can use dot-notation to navigate through linked records. Finally, we have some considerations on handling date and time records and converting them between different formats.

Accessing data on records

The special case of a recordset with only one record is called a singleton. Singletons are still a recordset and can be used wherever a recordset is expected. 

But unlike multi-element recordsets, singletons can access their fields using the dot-notation, like this:

>>> print(self.name) 
OdooBot

In the next example, we can see the same self singleton recordset also behaves as a recordset, and we can iterate it. It has only one record, so only one name is printed out:

>>> for rec in self: 
 ...