Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Odoo Development Cookbook
  • Table Of Contents Toc
  • Feedback & Rating feedback
Odoo Development Cookbook

Odoo Development Cookbook

By : Daudi, Vora, Gajjar, Fayolle, Holger Brunn, Daniel Reis
4.2 (12)
close
close
Odoo Development Cookbook

Odoo Development Cookbook

4.2 (12)
By: Daudi, Vora, Gajjar, Fayolle, Holger Brunn, Daniel Reis

Overview of this book

The latest version of the powerful Odoo framework uncovers a wide variety of features for rapid application development. Written by seasoned Odoo experts, this updated Odoo Development Cookbook will help you explore Odoo 17’s new features and use them to develop applications from scratch. You'll learn about website development concepts and get to grips with the Odoo Web Library (OWL), as well as create a new Odoo module from the ground up before progressing to advanced framework concepts. The book also shows you how to modify existing applications, including Point of Sale (POS) applications. Going beyond backend development, you'll discover advanced JavaScript recipes for creating new views and widgets. You'll get a clear understanding of website development and be on your way to becoming a proficient Odoo developer by studying performance optimization, debugging, and automated testing. By the end of this book, you'll have the knowledge you need to build impressive applications and be well-versed in Odoo development best practices.
Table of Contents (28 chapters)
close
close
17
Chapter 17: In-App Purchasing with Odoo

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

bookmark search playlist download font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY