Odoo Help


Many2many relation with attributs

on 5/6/16, 6:46 AM 728 views

Hello people please i need a quick help this is my py file:

class gestion_eleve(osv.osv):

_name = "gestion.eleve"

_rec_name= "nome"

_description = "Table des eleves"

_order = "nome asc"

_columns = {

'nume': fields.char('Num Eleve',required=True),

'nome': fields.char('Nom',required=True),

'group_id': fields.many2one('gestion.groupe','Groupe',ondelete='cascade'),

'anneescolaire': fields.char('Année Scolaire'),

'prenom': fields.char('Prénom'),

'daten': fields.date('Date Naissance'),

'lieunaissance': fields.char('Lieu de Naissance'),

'adresse': fields.char('Adresse'),

'niveau': fields.char('Niveau scolaire'),

'nompere': fields.char('Nom Père /Tuteur'),

'prenompere': fields.char('Prénom Père / Tuteur'),

'professionpere': fields.char('Profession Père / Tuteur'),

'telephonepere': fields.char('Téléphone Père / Tuteur'),

'emailpere': fields.char('Email Père / Tuteur'),

'nommere': fields.char('Nom Mère /Tuteur'),

'prenommere': fields.char('Prénom Mère / Tuteur'),

'professionmere': fields.char('Profession Mère / Tuteur'),

'telephonemere': fields.char('Téléphone Mère / Tuteur'),

'emailmere': fields.char('Email Mère / Tuteur'),

'image_small': fields.binary('Photo'),

'absence_ids' :fields.one2many('gestion.absence','eleve_id','Absences'),

'matiere_ids' :fields.many2many('gestion.matiere','note_rel','asso2_id','asso1_id','Matière'),


class gestion_matiere(osv.osv):

_name = "gestion.matiere"

_rec_name= "libelle"

_description = "Table des matieres"

_order = "numm asc"

_columns = {

'numm': fields.integer('Code matiére',required=True),

'libelle': fields.char('Libelle'),

'classe1_id': fields.many2one('gestion.classe','Classe',ondelete='cascade'),

'coef' : fields.integer('Coefficient matière'),

'prof_ids': fields.one2many('gestion.prof','matiere_id','Enseignants'),

'eleve_ids' :fields.many2many('gestion.eleve','note_rel','asso1_id','asso2_id','Elève'),


class gestion_note_matiere(osv.osv):

_name = "gestion.note.matiere"

_description = "table des notes"

_table = "note_rel"

_columns = {

'c1': fields.float('Controle 1'),

'c2': fields.float('Controle 2'),

'asso1_id': fields.many2one('gestion.matiere','Matière'),

'asso2_id': fields.many2one('gestion.eleve','Elève'),

'observation': fields.char('Observation'),

'note_general': fields.integer('Note/20'),


everithing ok when upgrading the module but when trying to get the list of the associative class i'm getting an error:

ProgrammingError: column note_rel.id does not exist
LINE 1: SELECT "note_rel".id FROM "note_rel" ORDER BY "note_rel"."id...                                

1# remove this one _table = "note_rel"

webkul, Prakash Sharma
on 5/6/16, 7:31 AM

because it's the same table used even if i changed the name i'm getting the same error message

on 5/6/16, 8:16 AM
Mohamed Essakali
On 5/6/16, 2:42 PM

The many2many table note_rel is created with just the two fields 

'asso1_id' and 'asso2_id', you can display field like 'matiere_ids' using many2many widget. If you want to let system creates all specific fields (id, create user, ...) you must create the relation class first (see this https://github.com/odoo/odoo/issues/2386)

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 5/6/16, 6:46 AM
Seen: 728 times
Last updated: 5/6/16, 2:42 PM