[英]how to use create() orm methode with loop ? odoo10
我想創建一年並使用orm方法create()
為其訂閱學生。 我嘗試過這種方式,但是我不認為這是怎么做的。 我使用Odoo 10(新API)。
class InsYear(models.Model):
_name = 'core.student.ins_year'
student_id = fields.Many2one('core.student',string='Student',required=True)
@api.depends('student_id')
def _year_creation_(self):
for student in self.env['student_id'].browse():
self.env['student_id'].create({
'registration_number':'',
'name_student':'',
'surname_student':''})
而學生的核心是:
class Student(models.Model):
_name = 'core.student'
registration_number = fields.Char('Student registration number ',required=True)
name_student =fields.Char('Student name ',required=True)
surname_student = fields.Char('Student surname ',required=True)
這樣嘗試
@api.depends('student_id')
def _year_creation_(self):
for student in self:
self.env['core.student'].create({
'registration_number':'',
'name_student':'',
'surname_student':''})
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.