54 lines
2.9 KiB
Python
54 lines
2.9 KiB
Python
from odoo import api,models,fields
|
|
|
|
class StudentInfo(models.Model):
|
|
_name="student.info"
|
|
|
|
stu_name=fields.Char(string="姓名",tracking=True)
|
|
stu_num=fields.Char(string="学号",tracking=True)
|
|
stu_sex = fields.Selection([('male', '男'),('female', '女')], string="性别", default='male', required=True)
|
|
stu_birthday = fields.Date(string="出生日期", tracking=True)
|
|
stu_id_card = fields.Char(string="身份证号", index=True, tracking=True)
|
|
stu_nation = fields.Char(string="民族", default="汉族")
|
|
stu_shenfen = fields.Selection([
|
|
('mass', '群众'),
|
|
('league', '共青团员'),
|
|
('party', '中共党员'),
|
|
('other', '其他')
|
|
], string="政治面貌", default='mass')
|
|
stu_phone = fields.Char(string="手机号")
|
|
stu_email = fields.Char(string="邮箱")
|
|
stu_address = fields.Text(string="家庭地址")
|
|
stu_emergency_contact = fields.Char(string="紧急联系人")
|
|
stu_emergency_phone = fields.Char(string="紧急联系电话")
|
|
stu_photo = fields.Binary(string="照片", attachment=True)
|
|
stu_begin_date = fields.Date(string="入学日期", required=True, tracking=True)
|
|
stu_end_date = fields.Date(string="毕业日期")
|
|
stu_grade_xx = fields.Many2one('basic.grade.xx',string="年级", tracking=True,domain = lambda self: self.env['basic.grade.xx']._get_current_year_range_domain())
|
|
stu_grade_bx=fields.Many2one('basic.grade.xx',string='年级',readonle=1)
|
|
stu_status = fields.Selection([
|
|
('studying', '在读'),
|
|
('graduated', '已毕业'),
|
|
('suspended', '休学'),
|
|
('expelled', '退学'),
|
|
('transferred', '转出')
|
|
], string="学籍状态", default='studying', tracking=True)
|
|
org_path = fields.Char(string='组织路径', compute='_compute_org_path',
|
|
store=True, index=True)
|
|
|
|
class_id = fields.Many2one('student.organization', string="行政班", tracking=True,domain="[('org_type', '=', 'class')]")
|
|
parent_path = fields.Char(related='class_id.parent_path',store=True)
|
|
class_name = fields.Char(string="班级名称", related='class_id.name', store=True)
|
|
major_id = fields.Many2one('student.organization', string="专业", tracking=True,domain="[('org_type', '=', 'major')]")
|
|
major_name = fields.Char(string="专业名称", related='major_id.name', store=True)
|
|
department_id = fields.Many2one('student.organization', string="院系",store=True,domain="[('org_type', '=', 'college')]")
|
|
|
|
|
|
# user_id = fields.Many2one('res.users', string="系统用户", ondelete='restrict')
|
|
@api.depends('parent_path')
|
|
def _compute_org_path(self):
|
|
for record in self:
|
|
if record.class_id:
|
|
# 直接使用班级的 parent_path + 班级ID
|
|
record.org_path = f"{record.class_id.parent_path}{record.class_id.id}/"
|
|
else:
|
|
record.org_path = False |