我从 OpenERP 7 中的按钮打开向导。但是当单击向导的计算按钮时,我的向导关闭了,但我不想在单击计算按钮时关闭向导,而不是在单击向导的关闭按钮时关闭向导。我正在使用 OpenERP 7。
class test_pass_student(osv.osv_memory):
_name = 'test.pass.student'
_column ={
'pass_id': fields.many2one('pass.student', 'Passed'),
'student_id':fields.many2one('student.student', 'Student'),
}
test_pass_student()
def _reopen(self, res_id, model):
return {'type': 'ir.actions.act_window',
'view_mode': 'form',
'view_type': 'form',
'res_id': res_id,
'res_model': self._name,
'target': 'new',
'context': {
'default_model': model,
},
}
class pass_student(osv.osv_memory):
_name = 'pass.student'
_columns = {
'student_id':fields.many2one('student.student', 'Student'),
'lines': fields.one2many('test.pass.student','pass_id', 'Passed students'),
}
def add_student(self, cr, uid, ids,context=None):
lines_obj = self.pool.get('test.pass.student')
for record in self.browse(cr,uid,ids,context):
for line in record.student_id.scores:
if line.pass_score > 50:
lines_obj.create(cr,uid,{'pass_id': record.id,'student_id':line.student_id.id})
return _reopen(self, record.id, record._model)
pass_student()
沉S选择第一个学生检查,如果他/她的分数大于50则添加one2many,然后再次检查另一个学生,同样的事情再次重复。