Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Odoo 12 Development Cookbook

You're reading from   Odoo 12 Development Cookbook 190+ unique recipes to build effective enterprise and business applications

Arrow left icon
Product type Paperback
Published in Apr 2019
Publisher Packt
ISBN-13 9781789618921
Length 774 pages
Edition 3rd Edition
Languages
Tools
Arrow right icon
Authors (4):
Arrow left icon
Parth Gajjar Parth Gajjar
Author Profile Icon Parth Gajjar
Parth Gajjar
Daniel Reis Daniel Reis
Author Profile Icon Daniel Reis
Daniel Reis
Holger Brunn Holger Brunn
Author Profile Icon Holger Brunn
Holger Brunn
Alexandre Fayolle Alexandre Fayolle
Author Profile Icon Alexandre Fayolle
Alexandre Fayolle
Arrow right icon
View More author details
Toc

Table of Contents (26) Chapters Close

Preface 1. Installing the Odoo Development Environment FREE CHAPTER 2. Managing Odoo Server Instances 3. Server Deployment 4. Creating Odoo Add-On Modules 5. Application Models 6. Basic Server-Side Development 7. Module Data 8. Debugging 9. Advanced Server-Side Development Techniques 10. Backend Views 11. Access Security 12. Internationalization 13. Automation, Workflows, and Printouts 14. Web Server Development 15. CMS Website Development 16. Web Client Development 17. In-App Purchasing with Odoo 18. Automated Test Cases 19. Managing, Deploying, and Testing with Odoo.sh 20. Remote Procedure Calls in Odoo 21. Performance Optimization 22. Point of Sale 23. Manage Emails in Odoo 24. IoT Box 25. Other Book You May Enjoy

Managing Odoo environments using the start command

We will often want to use custom or community modules with our Odoo instance. Keeping them in a separate directory makes it easier to install upgrades to Odoo or troubleshoot issues from our custom modules. We just have to add that directory to the add-ons path and they will be available in our instance, just like the core modules are.

It is possible to think about this module directory as an Odoo environment. The Odoo start command makes it easy to organize Odoo instances as directories, each with its own modules.

Getting ready

For this recipe, we need to have already installed Odoo. We are assuming that it will be located at ~/odoo-dev/odoo, and that virtualenv has been activated.

This means that the following command should successfully start an Odoo server:

$ ~/odoo-dev/odoo/odoo-bin

How to do it...

To create a work environment for your instance, you need to follow these steps:

  1. Change to the directory where Odoo is:
$ cd ~/odoo-dev
  1. Choose a name for the environment and create a directory for it:
$ mkdir my-odoo
  1. Change to that directory and start an Odoo server instance for that environment:
$ cd my-odoo/
$ ../odoo/odoo-bin start

How it works...

The Odoo start command is a shortcut to start a server instance using the current directory. The directory name is automatically used as the database name (for the -d option), and the current directory is automatically added to the add-ons path (the --addons-path option), as long as it contains an Odoo add-on module. In the preceding recipe, you won't see the current directory in the add-ons path because it doesn't contain any modules yet.

With the start command, if you are on the virtual environment, it will take the virtual environment name as the database instead of the directory that you are in. However, if you aren't in the virtual environment, this should work fine.

There's more...

By default, the current directory is used, but the --path option allows you to set a specific path that you can use instead. For example, this will work from any directory:

$ ~/odoo-dev/odoo/odoo-bin start --path=~/odoo-dev/my-odoo

The database to use can also be overridden using the usual -d option. In fact, all of the other usual odoo-bin command-line arguments will work, except --addons-path. For example, to set the server listening port, use the following command:

$ ../odoo/odoo-bin start -p 8080 -i base

As we can see, the Odoo start command can be a convenient way to quick-start Odoo instances with their own module directory.

You have been reading a chapter from
Odoo 12 Development Cookbook - Third Edition
Published in: Apr 2019
Publisher: Packt
ISBN-13: 9781789618921
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime