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

Writing on records


We have two different ways to write on records—using object-style direct assignment and using the write() method. The first one is simpler to use but only works with one record at a time and can be less efficient. Since each assignment performs a write operation, redundant recomputations may happen. The latter requires special syntax to write on relation fields, but a single command can write on several fields and records, and more efficient field recomputations.

Writing with object-style value assignment

Recordsets implement the active record pattern. This means that we can assign values to them, and these changes will be made persistent in the database. This is an intuitive and convenient way to manipulate data, but only works with one field and one record at a time.

 

Here is an example:

>>> root = self.env['res.users'].browse(1)
>>> print(root.name) 
OdooBot
>>> root.name = 'Superuser'
>>> print(root.name) 
Superuser

While using the active...