odoo关于清单文件__manifest__.py文件的介绍

关于清单文件的介绍

原文地址

清单文件声明一个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(字符串,必需)

人类能读懂的模块名字

  • version(str)

模块的版本号,应该遵循固定的版本号规则

版本格式:主版本号.次版本号.修订号,版本号递增规则如下:

主版本号:当你做了不兼容的 API 修改,
次版本号:当你做了向下兼容的功能性新增,
修订号:当你做了向下兼容的问题修正。
先行版本号及版本编译信息可以加到“主版本号.次版本号.修订号”的后面,作为延伸。
  • description (str)

    模块描述

  • author (str)

    模块作者

  • website (str)

    模块作者的网址

  • license (str, defaults: LGPL-3)

    开源授权,默认LGPL-3

  • category (str, default: Uncategorized)

    odoo的分类类别,粗略的商业模块分类. 虽然利用现有的分类是被推荐的,但是自定义的分类也会被立刻创建. 分类可用通过“/”来分隔,例如Foo / Bar will create a category Foo, a category Bar as child category of Foo, and will set Bar as the module’s category.

  • depends (list(str))

​ 被依赖的模块必须提前加载,一方面本模块用到了被依赖的模块也可能修改了他们定义的资源。 当一个模块被安装后,它所有的依赖项都会被提前安装。就像一个模块在加载前会提前加载所有的依赖项。

注意: base模块在任何odoo实例中都会被安装,但是你依然需要指定它作为依赖项,这样当base模块被升级的时候,你的模块也会被升级。

  • data (list(str))

    数据文件的列表, 被模块安装或者升级使用, 是一组以模块目录为根目录的文件路径列表。

  • demo (list(str))

    在demonstration mode 下使用的数据文件列表。

  • auto_install (bool or list(str), default: False)

    如果是true,那么当它依赖的模块被安装后,该模块会自动安装,就像sale和crm模块,当着两个模块被安装后sale_crm 会自动被安装

    如果是list, 没看懂:(

    if it is a list, it must contain a subset of the dependencies. This module will automatically be installed as soon as all the dependencies in the subset are installed. The remaining dependencies will be automatically installed as well. If the list is empty, this module will always be automatically installed regardless of its dependencies and these will be installed as well.

    {
        'name': 'Opportunity to Quotation',
        'version': '1.0',
        'category': 'Hidden',
        'description': """
    This module adds a shortcut on one or several opportunity cases in the CRM.
    ===========================================================================
    
    This shortcut allows you to generate a sales order based on the selected case.
    If different cases are open (a list), it generates one sales order by case.
    The case is then closed and linked to the generated sales order.
    
    We suggest you to install this module, if you installed both the sale and the crm
    modules.
        """,
        'depends': ['sale', 'crm'],
        'data': [
            'security/ir.model.access.csv',
            'data/crm_lead_merge_template.xml',
            'views/partner_views.xml',
            'views/sale_order_views.xml',
            'views/crm_lead_views.xml',
            'views/crm_team_views.xml',
            'wizard/crm_opportunity_to_quotation_views.xml'
        ],
        'auto_install': True,
        'uninstall_hook': 'uninstall_hook',
        'license': 'LGPL-3',
    }
    
    
  • external_dependencies (dict(key=list(str)))

    外部的依赖,是一个字典,key只有两个python 或者bin

    python表示依赖的python包,可以是一个列表

    bin 表示能在path环境变量中执行的命令

    当这些条件不能被满足,该模块不能被安装。

  • application (bool, default: False)

    True 表示是一个应用,在app中可用搜索到

    false 表示知识一个模块,为其他app提供服务

  • assets (dict)

    定义静态资源文件See the assets page for more details

    'assets': {
        'web.assets_backend': [
            'web/static/src/xml/**/*',
        ],
        'web.assets_common': [
            'web/static/lib/bootstrap/**/*',
            'web/static/src/js/boot.js',
            'web/static/src/js/webclient.js',
        ],
        'web.qunit_suite_tests': [
            'web/static/src/js/webclient_tests.js',
        ],
    },
    
  • installable (bool default: True)

    是否能安装,不能安装的模块有毛用呢?

  • maintainer (str)

    该模块的维护人员或者团队,通常是作者

  • {pre_init, post_init, uninstall}_hook (str)

    钩子函数,当该模块被安装或者卸载是执行的函数,他们的值是函数名,定义在模块的init文件中

    pre_init_hook(cursor) 模块安装前执行

    post_init_hook( cursor ,registry) 当模块安装好之后执行。

    uninstall_hook( cursor ,registry) 当模块卸载完之后执行。

    只有当这个模块需要的设置/清理非常困难或不可能通过api时,才应该使用这些钩子。

  • active (bool)

    过期的参数,被 auto_install代替。.

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值