我想浏览 many2many 字段但收到此错误:
文件“C:\Program Files (x86)\OpenERP 7.0\Server\server\openerp\addons\schoolem\schoolem_dispense_cours.py”,第 39 行,创建 AttributeError:'**browse_record_list' 对象没有属性
heure_cours_dispense_id
这是代码:
class schoolem_dispense_cours(osv.Model):
_name = 'schoolem.dispense_cours'
_columns = {
'name' : fields.char('Code',required=True,help="Champ automatique"),
'cours_id' : fields.many2one('schoolem.cours','Nom du Cour',required=True),
'aca_id' : fields.many2one('schoolem.aca','Annee Academique',required=True),
'enseignant_id' : fields.many2one('res.users','Enseignant',required=True),
'salle_de_classe_id' : fields.many2one('schoolem.salle_de_classe','Salle de classe',required=True),
'heure_cours_id' : fields.many2many('schoolem.heure_cours_dispense','schoolem_dispense_cours_heure_cours_dispense','dispense_cours_id','heure_cours_dispense_id','Heures de cour'),
#'heure_cours_id' : fields.many2many('schoolem.heure_cours_dispense',required=True),
}
def create(self, cr, uid, vals, context=None):
if not vals['heure_cours_id'][0][2]:
raise osv.except_osv(('Erreur!'), ('Une Programmation doit avoir au moins une heure de cours!'))
ids = self.search(cr,uid,[('aca_id','=',vals['aca_id'])])
created_hc = []
if ids :
for id in ids :
obj_disp_crs = self.pool.get('schoolem.dispense_cours').browse(cr,uid,id)
created_hc.append(obj_disp_crs.heure_cours_id.heure_cours_dispense_id)