Completing the addon module manifest

The manifest is an important piece for Odoo modules. It contains important information about it and declares the data files that should be loaded.

Getting ready

We should have a module to work with, already containing an __openerp__.py manifest file. You may want to follow the previous recipe to provide such a module to work with.

How to do it…

We will add a manifest file and an icon to our addon module:

  1. To create a manifest file with the most relevant keys, edit the module __openerp__.py file to look like this:
    # -*- coding: utf-8 -*-
    {
        'name': "Title",
        'summary': "Short subtitle phrase",
        'description': """Long description""",
        'author': "Your name",
        'license': "AGPL-3",
        'website': "http://www.example.com",
        'category': 'Uncategorized',
        'version': '9.0.1.0.0',
        'depends': ['base'],
        'data': ['views.xml'],
        'demo': ['demo.xml'],
    }
  2. To add an icon for the module, choose a PNG image to use and copy it to static/description/icon.png.

How it works…

The first line, containing coding: utf-8, is necessary for Python to process the file content as Unicode UTF-8. This way, we can use non-ASCII characters in the manifest.

The remaining content is a regular Python dictionary, with keys and values. The example manifest we used contains the most relevant keys:

  • name: This is the title for the module.
  • summary: This is the subtitle with a one-line description.
  • description: This is a long description, written in plain text or ReStructuredText (RST) format. It is usually surrounded by triple quotes, used in Python to delimit multiline texts. For an RST quickstart reference, visit http://docutils.sourceforge.net/docs/user/rst/quickstart.html.
  • author: This is a string with the name of the authors. When there is more than one, it is common practice to use a comma to separate their names, but note that it still should be a string, not a Python list.
  • license: This is the identifier for the license under which the module is made available. It is limited to a predefined list, and the most frequent option is AGPL-3. Other possibilities include LGPL-3, Other OSI approved license, and Other proprietary.
  • website: This is a URL people should visit to know more about the module or the authors.
  • category: This is used to organize modules in areas of interest. The list of the standard category names available can be seen at https://github.com/odoo/odoo/blob/master/openerp/addons/base/module/module_data.xml. But it's also possible to define other new category names here.
  • version: This is the modules' version numbers. It can be used by the Odoo app store to detect newer versions for installed modules. If the version number does not begin with the Odoo target version (for example, 8.0), it will be automatically added. Nevertheless, it will be more informative if you explicitly state the Odoo target version, for example, using 8.0.1.0.0 or 8.0.1.0 instead of 1.0.0 or 1.0.
  • depends: This is a list with the technical names of the modules it directly depends on. If none, we should at least depend on the base module. Don't forget to include any module defining XML IDs, Views, or Models referenced by this module. That will ensure that they all load in the correct order, avoiding hard-to-debug errors.
  • data: This is a list of relative paths to the data files to load with module installation or upgrade. The paths are relative to the module root directory. Usually, these are XML and CSV files, but it's also possible to have YAML data files. These are discussed in depth in Chapter 9, Module Data.
  • demo: This is the list of relative paths to the files with demonstration data to load. These will only be loaded if the database was created with the Demonstration Data flag enabled.

The image that is used as the module icon is the PNG file at static/description/icon.png.

Tip

Odoo is expected to have significant changes between major versions, so modules built for one major version are likely to not be compatible with the next version without conversion and migration work. Because of this, it's important to be sure about a module's Odoo target version before installing it.

There's more

Instead of having the long description in the module manifest, it's possible to have it in its own file. Since version 8.0, it can be replaced by a README file, with either a .txt, .rst, or an .md (Markdown) extension. Otherwise, include a description/index.html file in the module.

This HTML description will override a description defined in the manifest file.

There are a few more keys that are frequently used:

  • application: If this is True, the module is listed as an application. Usually, this is used for the central module of a functional area.
  • auto_install: If this is True, it indicates that this is a "glue" module, which is automatically installed when all its dependencies are installed.
  • installable: If this is True (the default value), it indicates that the module is available for installation.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.19.17