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

Creating new records


A frequent need when writing business logic methods is to create new records. This recipe explains how to create records of the res.partner model, which is defined in Odoo's base addon module. We will create a new partner representing a company, with some contacts.

Getting ready

You need to know the structure of the models for which you want to create a record, especially their names and types as well as any constraints existing on these fields (for example, whether some of them are mandatory). The res.partner model defined in Odoo has a very large number of fields, and to keep things simple, we will only use a few of these. Moreover, the model definition in Odoo uses the old API. To help you follow the recipe, here is a port of the model definition we will be using for the new API:

class ResPartner(models.Model):
    _name = 'res.partner'
    name = fields.Char('Name', required=True)
    email = fields.Char('Email')
    date = fields.Date('Date')
    is_company = fields...