Odoo Help

Welcome!

This community 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.

1

Many2many relation with attributs

By
hamza
on 5/6/16, 6:46 AM 326 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"

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

hamza
on 5/6/16, 8:16 AM
0
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)

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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