Table Of ContentOdoo 12 Development
Cookbook
Third Edition
190+ unique recipes to build effective enterprise and
business applications
Parth Gajjar
Alexandre Fayolle
Holger Brunn
Daniel Reis
BIRMINGHAM - MUMBAI
Odoo 12 Development Cookbook
Third Edition
Copyright © 2019 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.
Commissioning Editor: Aaron Lazar
Acquisition Editor: Alok Dhuri
Content Development Editor: Digvijay Bagul
Technical Editor: Ashi Singh
Copy Editor: Safis Editing
Language Support Editors: Mary McGowan, Storm Mann
Project Coordinator: Prajakta Naik
Proofreader: Safis Editing
Indexer: Manju Arasan
Graphics: Tom Scaria
Production Coordinator: Deepika Naik
First published: April 2016
Second edition: January 2018
Third edition: April 2019
Production reference: 1270419
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-78961-892-1
www.packtpub.com
mapt.io
Mapt is an online digital library that gives you full access to over 5,000 books and
videos, as well as industry leading tools to help you plan your personal development
and advance your career. For more information, please visit our website.
Why subscribe?
Spend less time learning and more time coding with practical eBooks and
Videos from over 4,000 industry professionals
Improve your learning with Skill Plans built especially for you
Get a free eBook or video every month
Mapt is fully searchable
Copy and paste, print, and bookmark content
Packt.com
Did you know that Packt offers eBook versions of every book published, with PDF
and ePub files available? You can upgrade to the eBook version at www.packt.com and
as a print book customer, you are entitled to a discount on the eBook copy. Get in
touch with us at [email protected] for more details.
At www.packt.com, you can also read a collection of free technical articles, sign up for
a range of free newsletters, and receive exclusive discounts and offers on Packt books
and eBooks.
Contributors
About the author
Parth Gajjar is Application Engineer at Odoo and has been working on Odoo for the
past 6 years. For the past year and a half, Parth has been working as a code reviewer
at Odoo India. During this time, he has worked in several departments of Odoo,
including offshore, migration, and research and development. During his time in
research and development, he has developed several key features in Odoo, including
the marketing automation module Odoo mobile app (The hybrid JavaScript Part),
mobile push notification, Less/CSS editor, Domain Selector widget, and the Qweb
report engine prototype. He often gives technical training to Odoo partners. Also, he
handes technical interviews at Odoo India.
I would like to thank my parents, brother, and wife for all of the support they have
given throughout writing this book. I would like to thank again my parents for
giving me the freedom and support to follow my ambitions throughout my
childhood.
Previous edition authors
Alexandre Fayolle started working with Linux and free software in the mid 1990s
and quickly became interested in the Python programming language. In 2012, he
joined Camptocamp to share his expertise on Python, PostgreSQL, and Linux with
the team implementing Odoo. He currently manages projects for Camptocamp and is
strongly involved in the Odoo Community Association. In his spare time, he likes to
play jazz on the vibraphone.
Holger Brunn has been a fervent open source advocate since he came into contact
with the open source market sometime in the nineties. He has programmed for ERP
and similar systems in different positions since 2001. For the last 10 years, he has
dedicated his time to TinyERP, which became OpenERP and evolved into Odoo.
Currently, he works at Therp BV in the Netherlands as a developer and is an active
member of the Odoo Community Association (OCA).
Daniel Reis has had a long career in the IT industry, mostly as a consultant
implementing business applications in variety of sectors, and today works for
Securitas, a multinational security services provider. He has been working with Odoo
(formerly OpenERP) since 2010, is an active contributor to the Odoo Community
Association projects, is currently a member of the board of the Odoo Community
Association, and collaborates with ThinkOpen Solutions, a leading Portuguese Odoo
integrator.
About the reviewers
Dharmang Soni has master's degree in Information Technology. He loves to do code
and has worked with multiple technologies and frameworks, such as ASP.NET,
Android (Java), PHP, iOS (Swift), and Odoo. He has more than 6 years' of experience
in development of Odoo applications, websites, and mobile applications. He joined
the Indian branch of Odoo S.A. (TinyERP Pvt. Ltd.) in 2012, starting his career at
Odoo by developing the Odoo mobile framework for the Android. Later, he
developed mobile applications for Android and iOS, currently used worldwide.
Currently, he is working as an R&D developer at Odoo and works on IoT and the
optimization of the screens for mobile.
I would like to thank my parents for their love, good advice, and continuous support.
I would also like to thank all my friends that I met along the way who enriched my
life, for motivating me and helping me progress.
Kishan Gajjar has a degree in computer engineering. He loves programming and
designing. He has expertise in various technologies, including Python, JavaScript, and
CSS. He is an employee at the Indian branch of Odoo. He joined Odoo 2 years ago
and currently works in the R&D department. At Odoo, he mostly works on website
builders, themes, and the backend JavaScript framework.
To begin with, I'd like to thank my parents for allowing me to follow my ambitions
throughout my childhood, and also my brother, who gives encouragement in his
particular way. He has been my inspiration and motivation for me continuing to
improve my knowledge and move my career forward.
Packt is searching for authors like you
If you're interested in becoming an author for Packt, please visit
authors.packtpub.com and apply today. We have worked with thousands of
developers and tech professionals, just like you, to help them share their insight with
the global tech community. You can make a general application, apply for a specific
hot topic that we are recruiting an author for, or submit your own idea.
Table of Contents
Preface 1
Chapter 1: Installing the Odoo Development Environment 9
Introduction 9
Odoo ecosystem 10
Odoo editions 10
Git repositories 11
Runbot 11
Odoo app store 12
Odoo community association 13
Official Odoo help forum 13
Easy installation of Odoo from a source 13
Getting ready 14
How to do it... 14
How it works... 17
Virtual environments 17
PostgreSQL configuration 19
Git configuration 20
Downloading the Odoo source code 20
Starting the instance 21
Managing Odoo environments using the start command 22
Getting ready 22
How to do it... 22
How it works... 23
There's more… 23
Managing Odoo server databases 23
Getting ready 24
How to do it... 24
Accessing the database management interface 24
Setting or changing the master password 24
Creating a new database 26
Duplicating a database 28
Removing a database 28
Backing up a database 29
Restoring a database backup 30
How it works... 31
There's more... 32
Storing the instance configuration in a file 34
How to do it... 34
How it works... 35
Activating the Odoo developer tools 38
Table of Contents
How to do it... 38
How it works... 39
Updating Odoo from source 40
Getting ready 40
How to do it... 40
How it works... 42
Chapter 2: Managing Odoo Server Instances 43
Introduction 43
Configuring the add-ons path 44
Getting ready 44
How to do it… 45
How it works… 45
There's more… 46
Updating the add-on modules list 47
Getting ready 47
How to do it… 47
How it works… 48
Standardizing your instance directory layout 49
How to do it… 49
How it works… 51
See also 52
There's more... 52
Installing and upgrading local add-on modules 53
Getting ready 53
How to do it… 54
From the web interface 54
From the command line 57
How it works… 58
Add-on installation 58
Add-on update 58
There's more… 60
Installing add-on modules from GitHub 60
Getting ready 61
How to do it… 61
How it works… 62
There's more… 62
Applying changes to add-ons 62
Getting ready 62
How to do it… 63
How it works… 63
See also 64
Applying and trying proposed pull requests 64
Getting ready 64
How to do it… 65
How it works… 65
[ ii ]
Table of Contents
There's more… 65
Chapter 3: Server Deployment 67
Introduction 67
Installing Odoo for production use 67
Getting ready 68
How to do it... 68
How it works... 70
There's more... 70
Server dimensioning 71
PostgreSQL tuning 71
Source code version 73
Backups 74
Adapting the configuration file for production 75
Getting ready 75
How to do it... 75
How it works... 77
There's more... 79
Setting up Odoo as a system service 80
Getting ready 80
How to do it... 80
How it works... 81
Configuring a reverse proxy and SSL with nginx and Let's
Encrypt 81
Getting ready 81
How to do it... 82
How it works... 85
There's more... 87
See also 88
Using Docker to run Odoo 89
Getting ready 89
How to do it… 89
How it works… 90
Running the Odoo image with a configuration file 90
Running the Odoo image with custom add-ons 91
Running multiple Odoo instances 91
There is more... 91
Running Odoo through docker-compose 92
Getting ready 92
How to do it... 92
How it works... 93
There's more... 94
Managing content delivery networks for websites 95
Getting ready 95
How to do it... 95
Configuring the CDN provider 96
[ iii ]