以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:建庫時是否自動安裝。