zoukankan      html  css  js  c++  java
  • openerp学习笔记 模块结构分析

    以OpenERP7.0中的 hr_expense 模块为例:

    如图中代码所示:

    __init__.py :和普通 Python 模块中的__init__.py 作用相同,主要用于引用模块根目录下的.py文件,是每个OpenERP 模块必须的。(注意,前后均是两个下划线)
    __openerp__.py :OpenERP 模块特有的,详细内容见后文,是每个OpenERP 模块必须的。
    hr_expense.py :费用单对象定义文件,Python代码。
    hr_expense_view.xml :费用单对象对应的视图(列表tree、表单form、搜索search)、动作(Action)、菜单(menu)定义文件。
    hr_expense_sequence.xml :费用单单据编号规则定义文件。
    hr_expense_workflow.xml :费用单工作流定义文件。
    hr_expense_report.xml :打印菜单定义文件,费用单打印中的“人力资源费用”菜单由此定义。关联Report文件夹下的打印模版文件和解析文件。
    hr_expense_data.xml :费用管理模块基础数据初始化文件。基础数据是模块正常运行必须的数据。
    hr_expense_demo.xml :演示数据定义文件。演示数据不是模块必须的数据。
    board_hr_expense_view.xml
    :费用单对应的报表(仪表盘)定义文件。

    文件夹:

    hr_expense:模块名,其他模块中引用当前模块中定义的对象时,需要使用 hr_expense. 前缀。

    i18n:翻译文件,zh_CN.po 为中文简体翻译文件。
    images:模块中主要功能截图展示文件。
    process :企业流程(Enterprise Process)定义相关文件。
    report :打印报表定义相关的文件,包括打印模版和解析文件。费用单打印中的“人力资源费用”报表在此定义。
    security :权限设置文件。通常包括两部分,ir_rule.xml 定义新的权限组(group)和角色(rule),ir.model.access.csv 定义权限组对对象(Object)的访问权限(增删改查)。
    static:模块中使用的静态文件,如模块中使用的图片、css、js 等资源文件。
    test:模块测试文件,供开发、测试人员使用。
    wizard:向导文件,如查询报表中的过滤条件向导,费用关联模块中未使用。

    其中需要特别介绍的为 __openerp__.py 文件,费用管理模块中该文件代码如下所示:

     1 # -*- coding: utf-8 -*-
     2 ##############################################################################
     3 #
     4 #    OpenERP, Open Source Management Solution
     5 #    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
     6 #
     7 #    This program is free software: you can redistribute it and/or modify
     8 #    it under the terms of the GNU Affero General Public License as
     9 #    published by the Free Software Foundation, either version 3 of the
    10 #    License, or (at your option) any later version.
    11 #
    12 #    This program is distributed in the hope that it will be useful,
    13 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
    14 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15 #    GNU Affero General Public License for more details.
    16 #
    17 #    You should have received a copy of the GNU Affero General Public License
    18 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    19 #
    20 ##############################################################################
    21 
    22 
    23 {
    24     'name': 'Leave Management',
    25     'version': '1.5',
    26     'author': 'OpenERP SA',
    27     'category': 'Human Resources',
    28     'sequence': 27,
    29     'summary': 'Holidays, Allocation and Leave Requests',
    30     'website': 'http://www.openerp.com',
    31     'description': """
    32 Manage leaves and allocation requests
    33 =====================================
    34 
    35 This application controls the holiday schedule of your company. It allows employees to request holidays. Then, managers can review requests for holidays and approve or reject them. This way you can control the overall holiday planning for the company or department.
    36 
    37 You can configure several kinds of leaves (sickness, holidays, paid days, ...) and allocate leaves to an employee or department quickly using allocation requests. An employee can also make a request for more days off by making a new Allocation. It will increase the total of available days for that leave type (if the request is accepted).
    38 
    39 You can keep track of leaves in different ways by following reports: 
    40 
    41 * Leaves Summary
    42 * Leaves by Department
    43 * Leaves Analysis
    44 
    45 A synchronization with an internal agenda (Meetings of the CRM module) is also possible in order to automatically create a meeting when a holiday request is accepted by setting up a type of meeting in Leave Type.
    46 """,
    47     'images': ['images/hr_allocation_requests.jpeg', 'images/hr_leave_requests.jpeg', 'images/leaves_analysis.jpeg'],
    48     'depends': ['hr', 'base_calendar', 'process', 'resource'],
    49     'data': [
    50         'security/ir.model.access.csv',
    51         'security/ir_rule.xml',
    52         'hr_holidays_workflow.xml',
    53         'hr_holidays_view.xml',
    54         'hr_holidays_data.xml',
    55         'hr_holidays_report.xml',
    56         'report/hr_holidays_report_view.xml',
    57         'report/available_holidays_view.xml',
    58         'wizard/hr_holidays_summary_department_view.xml',
    59         'wizard/hr_holidays_summary_employees_view.xml',
    60         'board_hr_holidays_view.xml',
    61         ],
    62     'demo': ['hr_holidays_demo.xml',],
    63     'test': ['test/test_hr_holiday.yml',
    64              'test/hr_holidays_report.yml',
    65     ],
    66     'installable': True,
    67     'application': True,
    68     'auto_install': False,
    69 }
    70 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

    其中:

    name :模块名,任意文字。
    version :版本号,如:1.0。

    author:作者。
    category:模块所属分类。
    sequence:序号,在本地模块列表中的显示顺序。
    summary:简要描述,在模块列表中显示。
    website:网站。
    description :模块详细描述,支持简单的富文本格式化显示,使用====,*号等标记。
    images:模块中主要功能截图展示文件。
    depends :依赖模块,即安装本模块时将检查此处定义的模块,如果没安装,将自动一起安装。通常所有模块都要依赖 base 模块。本例工作流要依赖 process 模块,员工及部门经理关系用到 hr 模块。
    data :模块安装和升级时需要重新加载的XML 文件,基础数据、权限、工作流、视图、报表等的定义文件通常放在此处。通常权限定义文件放在前面,因为其它文件常引用权限定义数据。
    demo :演示数据文件。
    test :测试文件。
    installable :是否启用安装,通常固定为True 。
    application:是否为应用程序。
    auto_install:建库时是否自动安装。

  • 相关阅读:
    mysql执行sql脚本
    Eclipse Memory Analyzer 进行堆转储文件分析
    JAVA字符串格式化-String.format()
    rpm 使用
    md5sum 使用
    Spring Security 初探
    java工厂模式
    Linux 定时任务
    Java Map 知识
    【转】MVC 比较
  • 原文地址:https://www.cnblogs.com/cnshen/p/3141771.html
Copyright © 2011-2022 走看看