1. 程式人生 > 其它 >odoo開發獨立模組

odoo開發獨立模組

模組基本目錄

各個檔案的內容

配置檔案:__manifest__.py 
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
{
    'name' : '疫情記錄', # 模組名
    'version' : '1.0', # 模組版本
    'summary': '疫情記錄', # 模組簡介
    'sequence': 1, # 模組排序
    'description': """
        疫情記錄
        """
, # 模組介紹 'author':'til', # 模組作者 'website':'til', # 模組站點 'data': [ 'views/epidemic_record_view.xml', 'security/ir.model.access.csv' ], # 模組用的到資料 檢視、許可權等 'application': True, # 是否作為獨立的app存在 }

model :epidemic_record.py

from odoo import api, fields, models


class
EpidemicRecord(models.Model): _name = 'epidemic.record' # 表名 name = fields.Char(string='姓名') # string是用於前端顯示的名字 date = fields.Date(string='確診日期') state = fields.Char(string='') city = fields.Char(string='') county = fields.Char(string='區/街道') street = fields.Char(string='
具體地址') ill_type = fields.Char(string='感染方式') within_or_abroad = fields.Selection([('within', '境內'), ('abroad', '境外')],string='境內/境外感染') # 列舉型別 is_ill = fields.Boolean(string='是否確診') begin_lsolation_date = fields.Date(string='起始隔離時間') lsolation_mode = fields.Selection([('home','居家隔離'),('focus','集中隔離')],string='隔離方式') create_user_id = fields.Many2one('res.users',string='填報人',default=lambda self:self.env.uid) # 外來鍵關聯,default是預設內容,這個函式的意思是預設值為當前登入使用者 note = fields.Text(string='說明')

許可權配置:ir.model.access.csv

id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_epidemic_record_group_user,epidemic.record,model_epidemic_record,base.group_user,1,1,1,1
name,
model_id:id
group_id:id
perm_read
perm_write
perm_create
perm_unlink