Table Of ContentOdoo 15 Development
Essentials
Fifth Edition
Enhance your Odoo development skills to create
powerful business applications
Daniel Reis
BIRMINGHAM—MUMBAI
Odoo 15 Development Essentials
Fifth Edition
Copyright © 2022 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or
transmitted in any form or by any means, without the prior written permission of the publisher,
except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the
information presented. However, the information contained in this book is sold without warranty,
either express or implied. Neither the authors, nor Packt Publishing or its dealers and distributors,
will be held liable for any damages caused or alleged to have been caused directly or indirectly by
this book.
Packt Publishing has endeavored to provide trademark information about all of the companies
and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing
cannot guarantee the accuracy of this information.
Group Product Manager: Alok Dhuri
Publishing Product Manager: Harshal Gundetty
Senior Editor: Ruvika Rao
Content Development Editor: Nithya Sadanandan
Technical Editor: Pradeep Sahu
Copy Editor: Safis Editing
Project Coordinator: Manisha Singh
Proofreader: Safis Editing
Indexer: Tejal Daruwale Soni
Production Designer: Ponraj Dhandapani
Marketing Coordinator: Teny Thomas
First published: November 2016
Fifth edition: February 2022
Production reference: 1030122
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-80020-006-7
www.packt.com
Thanks to Maria José Reis for all the companionship and support. This and
the previous books are a joint achievement.
– Daniel Reis
Foreword
It is an easy time to be an Odoo developer…and that wasn't always the case. In 2010,
when I first discovered OpenERP, the documentation was the code—and that was it.
Knowledge was widely dispersed and shallow, and the Odoo community was just a
mirage. Everything we all learned was through hard-won victories and transmitted as
tribal lore between pioneers.
Fortunately, a few people started writing down these lessons, making it easier for all that
followed. I must acknowledge the work that Fabien himself did in fostering this effort.
Daniel, Holger, Alex, and others built on this foundation, and now, we all benefit from
their largely unrecognized efforts.
The Odoo community has rocketed forward on a trajectory that all of us hoped for, but
none of us were sure how it would be done. Out of many free or open source software
projects, Odoo emerged as the most successful to tackle the enterprise resource planning
market, solving business problems with freedom and flexibility.
I am consistently amazed at the creativity and productivity that Odoo developers
demonstrate. Odoo attracts an especially curious, inspired sort of developer, and I think
this book will be a great help to people at all levels.
Finally, there is a question—how do I use Odoo to solve my business goals? That is where
the art is. This book does a good job of explaining how to build an application, but the
trick is in how to build the right application. Development effort alone isn't enough to
solve complex supply chain, manufacturing, or sales challenges. Thorough business
analysis and optimization are key to a successful project—and one of the people that I
think demonstrates this best is Daniel Reis. This book gives a few hints here and there that
business process optimization is as important as good code.
Here's to Fabien, Odoo S.A., and to the community—may we continue to work together as
friends and colleagues for decades to come.
Greg Mader
Founder and president of Open Source Integrators
Contributors
About the author
Daniel Reis has a degree in applied mathematics and an MBA. He has had a long career
in the IT industry, mostly as a consultant implementing business applications in a variety
of sectors.
He has been working with Odoo (OpenERP at the time) since 2010 and is an active
contributor to the Odoo Community Association (OCA), where he also serves as a
board member.
He is the managing director of Open Source Integrators, a leading open source and Odoo
consultancy firm.
About the reviewers
Bhavesh Odedra has been an innovative software developer since 2012 working on the
open source ERP software development lifecycle – from concept through delivery of
next-generation modules and customizable solutions. He started his journey with Odoo
(formerly OpenERP) in 2012. He has been an active contributor to the Stack Overflow
developer community and the Odoo Community Association since 2013 and is currently
a delegate member of the Odoo Community Association. Currently, he works at Open
Source Integrators in the United States as an implementation engineer.
Ashish Singh Bhatia is a reader and learner at his core. He has more than 13 years of rich
experience in different IT sectors, encompassing training, development, and management.
He has worked in many domains, such as software development, ERP, banking, and
training. He is passionate about Python and Java and has recently been exploring R. He is
mostly involved in web and mobile development in various capacities. He likes to explore
new technologies and share his views and thoughts through various online media and
magazines. He believes in sharing his experience with the new generation and also takes
part in training and teaching. Currently, he is working with Odoo's India office.
Table of Contents
Preface
Section 1: Introduction to Odoo
Development
1
Quick Start Using the Developer Mode
Technical requirements 4 Adding a custom field to a model 18
Introducing the to-do list project 4 Adding a field to a model 19
Understanding basic Adding a field to a form view 21
Odoo concepts 6 Understanding view types 24
About Odoo and the Odoo community 6 Creating a new model 26
Odoo product versions 7
Creating menu items
The Odoo architecture 8
and actions 30
Using an Odoo SaaS trial Configuring access control
database 10 security 32
Installing Odoo in your Security groups 33
workstation 11 Security access control lists 34
Installing on Windows using the Assigning security groups to users 34
all-in-one installer 12 Security record rules 36
Installing on Linux using a Understanding the superuser account 38
pre-packaged installer 12
Creating views 38
Installing Odoo using Docker containers 12
Creating a list view 39
Enabling the developer tools 15
Creating a form view 40
Enabling the developer mode 16 Creating search views 41
Using the developer mode with assets 18 Enabling default filters on views 42
About Odoo Studio 18
Summary 42
viii Table of Contents
2
Preparing the Development Environment
Technical requirements 44 Configuring the Odoo server
Setting up a host for the options 57
Odoo server 44 Odoo server configuration files 57
Installing the Windows Subsystem Changing the listening port 58
for Linux 45 Filtering the list of accessible databases 59
Managing server log messages 60
Installing Odoo from source 46
Finding and installing
Installing the PostgreSQL database 46
additional modules 63
Installing the Odoo system
dependencies 47 Finding community modules 63
Installing Odoo from source 48 Configuring the add-ons path 64
Running Odoo 51
Using the server
Creating a new database from the
development options 64
web client 52
Odoo commands quick
Creating a new database from the
command line 54 reference 65
Summary 66
Managing Odoo databases 55
3
Your First Odoo Application
Technical requirements 68 Step 2 – Creating a new
Overview of the library project 68 application 84
Step 1 – Creating a new Adding a top menu item 84
addon module 69 Adding security groups 85
Preparing the addons path 70 Step 3 – Adding automated tests 88
Creating a module directory 72
Adding test cases 90
Creating a manifest file 74
Running tests 91
Setting the module category 76
Testing business logic 91
Choosing a license 79
Testing access security 92
Adding a description 80
Adding an icon 81 Step 4 – Implementing the
Installing a new module 81 model layer 92
Upgrading modules 82 Creating a data model 93
Table of Contents ix
Step 5 – Setting up access Adding list and search views 109
security 97
Step 7 – Implementing the
Adding access control security 98
business logic layer 110
Row-level access rules 100
Adding business logic 110
Step 6 – Implementing the
Step 8 – Implementing the
backend view layer 102
website UI 112
Adding menu items 102
Adding the endpoint controller 113
Creating a form view 104
Adding a QWeb template 114
Business document form views 106
Adding action buttons 106 Quick reference 116
Using groups to organize forms 107
Access security 116
The complete form view 108
Summary 117
4
Extending Modules
Technical requirements 120 Copying models with prototype
inheritance 133
Learning project – extending
the Library app 120 Reusing model features using mixin
classes 134
Books 121
Adding message chatter and activities
Members 121
to a model 135
Adding a new field to an
Extending views and data 138
existing model 122
Extending views 138
Adding new fields with the in-place
Moving XML nodes to a
model extension 122
different location 139
Adding a field to the Form view 123
Using XPath to select
Extending models using classic XML extension points 140
in-place extension 125 Modifying existing data 140
Incrementally modifying existing fields 126 Extending web pages 142
Extending Python methods to add
Extending the web controllers 142
features to the business logic 127
Extending QWeb templates 144
More model inheritance
Summary 146
mechanisms 129
Further reading 147
Embedding models using
delegation inheritance 129