1. 新加自定义模块
odoo同级目录下新建my_addons文件夹
加入自己的模块(注意:views中也要创建一个xml文件)
2. model代码-写在models下面的py文件中
from odoo import api, fields, models class EpidemicRecord(models.Model): _name = 'epidemic.record' # 数据库表明 name = fields.Char(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='感染方式') with_or_abroad = fields.Selection([('within', '境内'), ('abroad', '境外')], string='境内/境外')
3. views代码-卸载views下面的xml文件中
<?xml version="1.0" encoding="UTF-8" ?> <odoo> <record id="epidemic_record_tree_view" model="ir.ui.view"> <field name="name">疫情记录</field> <field name="model">epidemic.record</field> <field name="arch" type="xml"> <tree> <field name="name"/> <field name="date"/> <field name="state"/> <field name="city"/> <field name="county"/> <field name="street"/> <field name="ill_type"/> <field name="with_or_abroad"/> </tree> </field> </record> <record id="epidemic_record_act_window" model="ir.actions.act_window"> <field name="name">疫情记录</field> <field name="res_model">epidemic.record</field> <field name="view_mode">tree, form</field> </record> <menuitem name="疫情记录" id="epidemic_record_menu_root" groups="base.group_user" sequence="10"/> <menuitem name="疫情记录" id="sec_epidemic_record_menu" parent="epidemic_record_menu_root" action="epidemic_record_act_window" sequence="10"/> </odoo>
标签:Char,string,views,fields,epidemic,学习,odoo From: https://www.cnblogs.com/JackShi/p/18280227