Odoo Help


one2many /many2one fields

Hachem Chraiti
on 4/3/14, 3:44 PM 3,295 views

Hi everyone, i have 2 classes (etudiant and faculte):a faculte contain 0..* etudiant and an etudiant belong to 1 faculte==> son its one2many /many2one relation

from openerp.osv import fields, osv from openerp.addons.TestModuleHachem.pos_faculte import pos_faculte

class pos_etudiant(osv.osv): _name = 'pos.etudiant' _columns = { 'pos_etudiant_id' : fields.integer('ID',size=64), 'etudiant_nom': fields.char('Nom de la etudiant', size=128, required=True), 'etudiant_prenom': fields.char('Prenom de la etudiant', size=128, required=True), 'etudiant_date': fields.date('Date Naissance'), 'faculte':fields.many2one('pos.faculte','faculte_name'), }

_defaults = {
    'etudiant_nom' : '',
    'etudiant_prenom': '',


-----from openerp.osv import fields, osv

class pos_faculte(osv.osv): _name = 'pos.faculte' _columns = { 'pos_faculte_id' : fields.integer('ID',size=64), 'faculte_name': fields.char('Nom de la Faculte', size=128, required=True), 'faculte_pays': fields.char('Lieu de la Faculte', size=128, required=True), 'active': fields.boolean('Active', help="If a faculty is not active, it will not be displayed in POS"), 'systeme':fields.selection((('Ing', 'Ing'), ('Master', 'Master'), ('License', 'License')), 'Systeme dEtude' ), 'etudiant':fields.one2many('pos.etudiant','etudiant_nom'), }

_defaults = {
    'faculte_name' : '',
    'faculte_pays': 'Tunisie',
    'active' : True,


how cani display the faculte_name in the faculte class or view???????????

On 4/3/14, 4:25 PM

Not sure about tour question, but i see no field name for pos_falculte, so in the pos_faculte class add

_rec_name = 'faculte_name'

So openerp will know which field to use to display name in the pos.etudiant form for the falcute field

and this id bas




thankss :))

Hachem Chraiti
on 4/3/14, 5:19 PM

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: 4/3/14, 3:44 PM
Seen: 3295 times
Last updated: 3/16/15, 8:10 AM