各位前辈,我照着官方文档做demo的时候,想向[font=verdana][size=2px]Course类[/size][/font]中添加课程代码,但是添加后一直报错,希望各位前辈能帮帮我。拜谢!!
class Course(models.Model):
"""docstring for Course"""
_name = 'openacademy.course'
name = fields.Char(string=u'课程名称', required=True)
description = fields.Text(string=u'描述')
responsible_id = fields.Many2one('res.users', ondelete='set null', string=u'负责人', index=True)
session_ids = fields.One2many('openacademy.session', 'course_id', string=u'课程安排')
courseNo = fields.Char(string=u'课程代码', readonly=True)
_sql_constraints = [
('name_description_check',
'CHECK(name != description)',
u"课程的名称不应该描述"),
('name_unique',
'UNIQUE(name)',
u"课程名称必须是唯一的"),
]
def create(self, cr, uid, vals, context=None):
vals['courseNo'] = self.pool.get('ir.sequence').get(cr, uid, 'openacademy.course')
return super(openacademy.course, self).create(cr, uid, vals, context=context)