Odoo 11 Development Cookbook(Second Edition)
上QQ阅读APP看书,第一时间看更新

There's more…

When you call the odoo-bin script for the first time to initialize a new database, you can pass the --addons-path command-line argument with a comma-separated list of directories. This will initialize the list of available addon modules with all of the addons found in the supplied addons path. When you do this, you have to explicitly include the base addons directory (odoo/odoo/addons) as well as the core addons directory (odoo/addons). Be careful if you put a space after the commas, as you will need to quote the list of directories.

A small difference with the preceding recipe is that the local addons must not be empty; they must contain at least one subdirectory, which has the minimal structure of an addon module. We will see in detail in Chapter 4, Creating Odoo addon modules, how to write your own modules. In the meantime, here's a quick hack produce, something that will make Odoo happy:

$ mkdir -p ~/odoo-dev/local-addons/dummy
$ touch ~/odoo-dev/local-addons/dummy/__init__.py
$ echo '{"name": "dummy", "installable": False}' > \
~/odoo-dev/local-addons/dummy/__manifest__.py

You can use the --save option to also save the path to the configuration file:

$ odoo/odoo-bin -d mydatabase \
--addons-path="odoo/odoo/addons,odoo/addons,~/odoo-dev/local-addons" \
--save -c ~/odoo-dev/my-instance.cfg --stop-after-init

In this case, using relative paths is okay, since they will be converted to absolute paths in the configuration file.

Since Odoo only checks directories in the addons path for the presence of addons when the path is set from the command line, not when the path is loaded from a configuration file, the dummy module is no longer necessary. You may, therefore, remove it (or keep it for some time until you're sure that you won't need to create a new configuration file).