Odoo Help


Following one2many field in another module

on 6/21/13, 3:57 PM 1,214 views

Hi everyone i try to recover a field cost_ids(one2many field in my class school.classe) following the branche_niveau_id(in my class school.cls)

but i find an empty list

enter code hereclass school_classe(osv.osv):
_name = 'school.classe'
_columns = {
    'name': fields.char('libelle classe', size=64),
    'cost_ids': fields.one2many('school.agenda', 'parent_id', 'Included Services'),


class school_cls(osv.osv):
_name = 'school.cls'
def get_total_mat(self, cr, uid, ids, fields, args, context=None):
    res = {}
    for classemat in self.browse(cr, uid, ids):
        total = len(self.pool.get("school.classe").search(cr, uid, [('cost_ids','=',classemat.id)]))
        res[classemat.id] = total
    return res  
_columns = {
    'name': fields.char('Nom', size=64, required=True, select=1),
    'branche_niveau_id':fields.many2one('school.classe','Classe Academique',required=True),
    'total_mat':fields.function(get_total_mat, string="Effectif de matieres", type="integer"),


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

0 follower(s)


Asked: 6/21/13, 3:57 PM
Seen: 1214 times
Last updated: 3/16/15, 8:10 AM