36 lines
1.3 KiB
Python
36 lines
1.3 KiB
Python
from odoo import fields, models
|
|
|
|
_COLLEGE_SELECTION = [
|
|
('computer', '计算机学院'),
|
|
('software', '软件学院'),
|
|
('business', '商学院'),
|
|
('foreign', '外国语学院'),
|
|
('mechanic', '机械工程学院'),
|
|
('electric', '电子信息学院'),
|
|
('math', '数学学院'),
|
|
('other', '其他'),
|
|
]
|
|
|
|
|
|
class SchoolStudent(models.Model):
|
|
"""学生档案——来自组织架构,可关联登录账号用于学生端提交/查看。"""
|
|
|
|
_name = 'yuthon.school.student'
|
|
_description = '学生'
|
|
_order = 'student_number, name'
|
|
|
|
name = fields.Char(string='姓名', required=True, index=True)
|
|
user_id = fields.Many2one(
|
|
'res.users', string='登录账号', ondelete='restrict',
|
|
help='关联该学生的 Odoo 登录账号;不填则仅作为选课名单,无法独立登录。')
|
|
student_number = fields.Char(string='学号', index=True)
|
|
gender = fields.Selection(
|
|
[('male', '男'), ('female', '女')], string='性别')
|
|
class_id = fields.Many2one(
|
|
'yuthon.school.class', string='班级', ondelete='set null')
|
|
college = fields.Selection(_COLLEGE_SELECTION, string='学院')
|
|
phone = fields.Char(string='联系电话')
|
|
email = fields.Char(string='邮箱')
|
|
note = fields.Text(string='备注')
|
|
active = fields.Boolean(string='启用', default=True)
|