Table Of ContentOdoo Development
Cookbook
Build effective applications by applying Odoo development
best practices
Holger Brunn
Alexandre Fayolle
Daniel Reis
BIRMINGHAM - MUMBAI
Odoo Development Cookbook
Copyright © 2016 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, and its dealers
and distributors will be held liable for any damages caused or alleged to be 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.
First published: April 2016
Production reference: 1260416
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78588-364-4
www.packtpub.com
FM-2
Credits
Authors Project Coordinator
Holger Brunn Kinjal Bari
Alexandre Fayolle
Proofreader
Daniel Reis
Safis Editing
Reviewers
Indexer
Guewen Baconnier
Monica Ajmera Mehta
Stefan Rijnhart
Production Coordinator
Acquisition Editor
Arvindkumar Gupta
Manish Nainani
Cover Work
Content Development Editor
Arvindkumar Gupta
Mehvash Fatima
Technical Editors
Menza Mathew
Deepti Tuscano
Copy Editors
Merilyn Pereira
Alpha Singh
FM-3
About the Authors
Holger Brunn has been a fervent open source advocate since he came in to contact
with the open source market sometime in the nineties. With an academic background in
philosophy and sociology, he turned his interest to generalized logic, which proves helpful in
many aspects of his IT work. Turning into a professional programmer was a side effect of his
hobbyist interest, combined with a part-time job with a very open-minded mentor to whom he
owes a lot of gratitude.
He has programmed for ERP and similar systems in different positions since 2001. For the
last eight 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). He's most interested in fundamental work
on technical modules, but also enjoys contributing to other projects, with a focus on UI and
website widgets, CRM, and knowledge management.
Alexandre Fayolle started working with Linux and free software in the mid 1990s and
quickly became interested in the Python programming language. Between 1999 and 2012, he
helped manage Logilab, a company he cofounded, he specialized in Python development, and
had the opportunity to work on projects for large companies such as EDF, Arcelor-Mittal, and
GdF Suez (now Engie) using the Cubicweb framework.
He also tackled fun projects involving machine learning, natural language processing, and
multi-agent systems. In 2012, he joined Camptocamp to share his expertise on Python,
PostgreSQL, and Linux with the team implementing Odoo (OpenERP at the time). He
currently manages projects for Camptocamp and is strongly involved in the Odoo Community
Association. In his spare time, he likes to play the vibraphone in a jazz quartet, but has
recently been known for writing a book about Odoo, which he hopes you'll enjoy.
FM-4
Daniel Reis has been working in the IT industry for over 15 years in developer, consultant,
and management roles. Most of this work was at the Capgemini multinational consultancy
firm, implementing proprietary business solutions for reference companies in a variety of
sectors, such as industry, telecommunications, and banking. Daniel has a BSc in applied
mathematics and a master's in business administration from the ISCTE Business School.
He's worked with Odoo solutions (formerly OpenERP) since 2010, and he is an active
contributor in the Odoo community association projects. He has been a speaker at the Open
Days annual conference and other open source events. He is the author of the first Odoo
development book: Odoo Development Essentials, also by Packt Publishing.
He currently works at Securitas, the global security services company, where he has
introduced Python, Odoo, and other open source solutions into the company's IT
applications portfolio.
I thank my wife, Maria José, for all the support and patience that made this
book possible.
FM-5
About the Reviewers
Guewen Baconnier is a discrete guy who does not enjoy being put forward. He works
at Camptocamp where he's been a TinyERP programmer before moving to OpenERP and
now Odoo. He is a free software enthusiast and an active member of the Odoo Community
Association (OCA), where his responsibilities involve, among others, being the lead developer
of the OCA Connector Framework. Guewen also loves books so should you come across him,
there is a good chance he may have his nose in one, either reading a technical book to keep up
with his boundless curiosity and hunger to learn, or reading a novel to journey in some fictional
universe, or whatever good read fell into his hands. He likes to hike in the countryside with his
beloved wife. He is also the happy father of two nice kids, with whom he enjoys spending time,
strolling, going to the library, reading books, and playing Kerbal Space Program.
I would like to thank my wife and kids for supporting my tiredness on the
morrows of long evenings of reviewing. And I would like to thank Alexandre
Fayolle who helped me shape this short biography. Finally, thanks to my
colleagues and to all contributors of the OCA from whom I learn every day.
Stefan Rijnhart is a life-long open source advocate and has been a full time Odoo
consultant and developer since 2010. He enjoys collaborating in the Odoo Community
Association (OCA), which he finds to be mutually beneficial to his customers' projects. In the
OCA, Stefan played a key role in the creation of the OpenUpgrade migration project for Odoo
and in the Odoo Community Backports project (OCB). Offline, you can find him riding a carrier
bicycle through the streets of Amsterdam with his son on the front seat, or playing music with
his band. Get in touch with Stefan at http://opener.amsterdam.
FM-6
www.PacktPub.com
eBooks, discount offers, and more
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.PacktPub.com and as a print
book customer, you are entitled to a discount on the eBook copy. Get in touch with us at
customercare@packtpub.com for more details.
At www.PacktPub.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.
TM
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book
library. Here, you can search, access, and read Packt's entire library of books.
Why subscribe?
f Fully searchable across every book published by Packt
f Copy and paste, print, and bookmark content
f On demand and accessible via a web browser
FM-7
Table of Contents
Preface vii
Chapter 1: Installing the Odoo Development Environment 1
Introduction 1
Easy installation of Odoo from source 2
Managing Odoo environments using the start command 9
Managing Odoo server databases 10
Storing the instance configuration in a file 19
Activating the Odoo developer tools 22
Updating Odoo from source 25
Chapter 2: Managing Odoo Server Instances 29
Introduction 29
Configuring the addons path 30
Updating the addon modules list 31
Standardizing your instance directory layout 33
Installing and upgrading local addon modules 36
Installing addon modules from GitHub 40
Applying changes to addons 42
Applying and trying proposed pull requests 43
Chapter 3: Creating Odoo Modules 47
Introduction 47
Creating and installing a new addon module 48
Completing the addon module manifest 49
Organizing the addon module file structure 52
Adding models 55
Adding Menu Items and Views 57
Using scaffold to create a module 61
i