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.

0

one2many /many2one fields

By
Hachem Chraiti
on 4/3/14, 3:44 PM 1,945 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': '',
    }

pos_etudiant()

-----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,
    'systeme':'Ing',
    }

pos_faculte()

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

0
Serge
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

'etudiant':fields.one2many('pos.etudiant','etudiant_nom')

use

'etudiant':fields.one2many('pos.etudiant','faculte',string='Etudiants')

thankss :))

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

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