general code
This commit is contained in:
@@ -5,8 +5,21 @@ class AcademyStudent(models.Model):
|
||||
_description = 'Academy Student'
|
||||
|
||||
name = fields.Char(string='Tên học sinh', required=True)
|
||||
code = fields.Char(string='Mã học sinh', required=True)
|
||||
code = fields.Char(string='Mã học sinh', required=True, copy=False, readonly=True, default=lambda self: _(' '))
|
||||
birth_date = fields.Date(string='Ngày sinh')
|
||||
email = fields.Char(string='Email')
|
||||
phone = fields.Char(string='Số điện thoại')
|
||||
course_ids = fields.Many2many('academy.course', string='Các khóa học học sinh đăng ký')
|
||||
course_ids = fields.Many2many('academy.course', string='Các khóa học học sinh đăng ký')
|
||||
|
||||
_sql_constraints = [(
|
||||
'code_unique',
|
||||
'unique(code)',
|
||||
'Mã học sinh phải là duy nhất!'
|
||||
)]
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
for vals in vals_list:
|
||||
if vals.get('code', _(' ')) == _(' '):
|
||||
vals['code'] = self.env['ir.sequence'].next_by_code('academy.student') or 'HS001'
|
||||
return super().create(vals_list)
|
||||
Reference in New Issue
Block a user