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

Following one2many field in another module

By
oumaima
on 6/21/13, 3:57 PM 745 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'),
}

school_classe()

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),
    'mat_ids':fields.one2many('school.classe','cost_ids','Matieres'),
    'total_mat':fields.function(get_total_mat, string="Effectif de matieres", type="integer"),
}

school_cls()

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

0 follower(s)

Stats

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