官术网_书友最值得收藏!

Configuring the addons path

The addons path is a configuration parameter that lists the directories, which will be searched for addon modules by Odoo when it initializes a new database.

Directories listed in the addons path are expected to contain subdirectories, each of which is an addon module.

Getting ready

This recipe assumes you have an instance ready, with a configuration file generated as described in Chapter 1, Installing the Odoo Development Environment. The source code of Odoo is available in ~/odoo-dev/odoo, and the configuration file is in ~/odoo-dev/my-instance.cfg.

How to do it…

To add the directory ~/odoo-dev/local-addons to the addons path of the instance, follow these steps:

  1. Edit the configuration file for your instance ~/odoo-dev/my-instance.cfg
  2. Locate the line starting with addons_path =. By default, it should look like the following:
    addons_path = ~/odoo-dev/odoo/openerp/addons,~/odoo-dev/odoo/addons
    
  3. Modify the line by appending a comma followed by the name of the directory you want to add to the addons path:
    addons_path = ~/odoo-dev/odoo/openerp/addons,~/odoo-dev/odoo/addons,~/odoo-dev/local-addons
    

    You can tidy that line a little by adding a root variable and using it to shorten the path definition (see Chapter 1, Installing the Odoo Development Environment, for more on this):

    root = ~/odoo-dev
    addons_path = %(root)s/odoo/openerp/addons,%(root)s/odoo/addons,%(root)s/local-addons
    
  4. Restart your instance:
    $ ~/odoo-dev/odoo/odoo.py -c my-instance.cfg
    

How it works…

When Odoo is restarted, the configuration file is read. The value of the addons_path variable is expected to be a comma-separated list of directories. Relative paths are accepted, but they are relative to the current working directory, and therefore should be avoided in the configuration file.

At this point, the new addons present in ~/odoo-dev/local-addons are not available in the list of available addon modules of the instance. For this, you need to perform an extra operation explained in the next recipe, Updating the addon modules list.

There's more…

When you call the odoo.py 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 the addons found in the supplied addons path. When you do this, you have to explicitly include the base addons directory (odoo/openerp/addons) as well as the core addons directory (odoo/addons). Be careful—if you put a space after the commas—you will need to quote the list of directories. You can use the --save option to also save the path to the configuration file:

$ odoo/odoo.py -d mydatabase \
--addons-path="odoo/openerp/addons,odoo/addons,local-addons" \
--save -c odoo-project.cfg –stop-after-init

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

主站蜘蛛池模板: 明星| 龙海市| 达孜县| 霍城县| 舟山市| 壤塘县| 张家口市| 巴东县| 嘉义县| 七台河市| 广东省| 普格县| 花莲县| 英超| 晋州市| 文成县| 淮南市| 金华市| 青冈县| 湛江市| 荣成市| 景德镇市| 郑州市| 晋城| 石柱| 江都市| 丰县| 广河县| 天门市| 昆山市| 阿克| 平乐县| 灵寿县| 沂南县| 两当县| 咸丰县| 壶关县| 贺州市| 都江堰市| 翁牛特旗| 中牟县|