模块清单

清单

清单文件用于将Python包声明为Odoo模块并指定模块元数据。

这是一个名为 __manifest__.py 的文件,包含一个 Python 字典,其中每个键指定模块元数据。

{
    'name': "A Module",
    'version': '1.0',
    'depends': ['base'],
    'author': "Author Name",
    'category': 'Category',
    'description': """
    Description text
    """,
    # data files always loaded at installation
    'data': [
        'views/mymodule_view.xml',
    ],
    # data files containing optionally loaded demonstration data
    'demo': [
        'demo/demo_data.xml',
    ],
}

可用的清单字段为:

name (str, required)

模块的可读名称

version (str)

此模块的版本应遵循 语义化版本 规则

description (str)

模块的扩展描述,使用reStructuredText格式

author (str)

模块作者的姓名

website (str)

模块作者的网站 URL

license (str, defaults: LGPL-3)

模块的分发许可证。可能的值:

  • GPL-2

  • GPL-2 or any later version

  • GPL-3

  • GPL-3 or any later version

  • AGPL-3

  • LGPL-3

  • Other OSI approved licence

  • OEEL-1 (Odoo Enterprise Edition License v1.0)

  • OPL-1 (Odoo Proprietary License v1.0)

  • Other proprietary

category``(``str,默认值:Uncategorized

Odoo中的分类类别,模块所属的大致业务领域。

虽然建议使用 现有类别,但该字段是自由格式的,未知类别会即时创建。可以使用分隔符 / 创建类别层次结构,例如 Foo / Bar 将创建一个类别 Foo,一个作为 Foo 子类别的类别 Bar,并将 Bar 设置为模块的类别。

depends (list(str))

必须在此模块之前加载的Odoo模块,因为此模块使用它们创建的功能或更改它们定义的资源。

当一个模块被安装时,它的所有依赖项都会在它之前被安装。同样,在加载模块之前会先加载依赖项。

注解

模块 base 在任何 Odoo 实例中都已安装。但是,您仍然需要将其指定为依赖项,以确保在更新 base 时更新您的模块。

data (list(str))

必须始终与模块一起安装或更新的数据文件列表。从模块根目录开始的路径列表

demo (list(str))

仅在 演示模式 下安装或更新的数据文件列表

auto_install``(``boollist(str),默认值:False

如果 True,当所有依赖项都被安装时,该模块将自动安装。

通常用于实现两个独立模块之间的协同集成的“链接模块”。

例如, sale_crm 依赖于 salecrm ,并设置为 auto_install 。当 salecrm 都被安装时,它会自动将 CRM 活动跟踪添加到销售订单中,而 无需 salecrm 之间相互感知。

如果是一个列表,它必须包含依赖项的子集。只要子集中的所有依赖项都安装完毕,此模块将自动安装。剩余的依赖项也将自动安装。如果列表为空,则无论其依赖项如何,此模块都将始终自动安装,并且这些依赖项也将被安装。

external_dependencies (dict(key=list(str)))

一个包含 Python 和/或二进制依赖项的字典。

对于 Python 依赖项,必须为此字典定义 python 键,并将要导入的 Python 模块列表分配给它。

对于二进制依赖项,必须为此字典定义 bin 键,并将二进制可执行文件的列表分配给它。

如果主机上未安装Python模块或二进制可执行文件未在主机的PATH环境变量中找到,则该模块将不会安装。

application``(``bool,默认值:False

模块是否应被视为一个完整的应用程序(True)或仅仅是一个技术模块(False),为现有应用程序模块提供一些额外的功能。

assets (dict)

定义了如何将所有静态文件加载到不同的资源包中。有关如何描述资源包的详细信息,请参阅 assets 页面。

installable``(``bool 默认值:True

用户是否应该能够从Web UI安装模块。

maintainer (str)

负责维护此模块的个人或实体,默认情况下,假定作者是维护者。

{pre_init, post_init, uninstall}_hook (str)

Hooks for module installation/uninstallation, their value should be a string representing the name of a function defined inside the module’s __init__.py.

pre_init_hook takes a cursor as its only argument, this function is executed prior to the module’s installation.

post_init_hook takes a cursor and a registry as its arguments, this function is executed right after the module’s installation.

uninstall_hook takes a cursor and a registry as its arguments, this function is executed after the module’s uninstallation.

这些钩子应该仅在通过 API 进行此模块的设置/清理非常困难或不可能时使用。

active (bool)

已弃用。已被 auto_install 取代。