Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
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 Development Cookbook

You're reading from   Odoo Development Cookbook Build effective business applications using the latest features in Odoo 17

Arrow left icon
Product type Paperback
Published in May 2024
Publisher Packt
ISBN-13 9781805124276
Length 774 pages
Edition 5th Edition
Languages
Tools
Arrow right icon
Authors (6):
Arrow left icon
Holger Brunn Holger Brunn
Author Profile Icon Holger Brunn
Holger Brunn
Husen Daudi Husen Daudi
Author Profile Icon Husen Daudi
Husen Daudi
Daniel Reis Daniel Reis
Author Profile Icon Daniel Reis
Daniel Reis
Jay Vora Jay Vora
Author Profile Icon Jay Vora
Jay Vora
Parth Gajjar Parth Gajjar
Author Profile Icon Parth Gajjar
Parth Gajjar
Alexandre Fayolle Alexandre Fayolle
Author Profile Icon Alexandre Fayolle
Alexandre Fayolle
+2 more Show less
Arrow right icon
View More author details
Toc

Table of Contents (28) Chapters Close

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

Storing the instance configuration in a file

The odoo-bin script has dozens of options, and it is tedious to remember them all, as well as how to remember to set them properly when starting the server. Fortunately, it is possible to store them all in a configuration file and only specify the ones you want to alter for development, for example.

How to do it...

For this recipe, perform the following steps:

  1. To generate a configuration file for your Odoo instance, run the following command:
    $ ./odoo-bin --save --config myodoo.cfg --stop-after-init
  2. You can add additional options, and their values will be saved in the generated file. All the unset options will be saved with their default value set. To get a list of possible options, use the following command:
    $ ./odoo-bin --help | less

    This will provide you with some help about what the various options perform.

  3. To convert from the command-line form into the configuration form, use the long option name, remove the leading dashes, and convert the dashes in the middle into underscores. So, in this case, --without-demo will become without_demo. This works for most options, but there are a few exceptions, all of which are listed in the following section.
  4. Edit the myodoo.cfg file (use the table in the following section for some parameters you may want to change). Then, to start the server with the saved options, run the following command:
    $ ./odoo-bin -c myodoo.cfg

Note

The --config option is commonly abbreviated as -c.

How it works...

At startup, Odoo loads its configuration in three passes. First, a set of default values for all options is initialized from the source code. After, the configuration is parsed, and then any value that’s defined in the file overrides the defaults. Finally, the command-line options are analyzed, and their values override the configuration that was obtained from the previous pass.

As we mentioned earlier, the names of the configuration variables can be found by looking at the names of the command-line options by removing the leading dashes and converting the middle dashes into underscores. There are a few exceptions to this, notably the following:

Table 1.1 – Difference in Odoo parameters regarding the command line and the configuration file

Table 1.1 – Difference in Odoo parameters regarding the command line and the configuration file

Here’s a list of options that are commonly set through the configuration file:

Table 1.2 – Odoo parameters and their usage

Table 1.2 – Odoo parameters and their usage

Here’s a list of configuration options related to the database:

Table 1.3 – Odoo parameters and their usage

Table 1.3 – Odoo parameters and their usage

The configuration file is parsed by Odoo using the Python ConfigParser module. However, the implementation in Odoo 11.0 has changed, and it is no longer possible to use variable interpolation. So, if you are used to defining values for variables from the values of other variables using the %(section.variable)s notation, you will need to change your habits and revert to explicit values.

Some options are not used in config files, but they are widely used during development:

Table 1.4 – Odoo parameters and their usage

Table 1.4 – Odoo parameters and their usage

lock icon The rest of the chapter is locked
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