Odoo Help

0

get som of a list

By
hamza
on 5/6/16, 11:41 AM 488 views

how can i get the som of coef for every classe

class gestion_classe(osv.osv):

_name = "gestion.classe"

_rec_name = "nomc"

_description = "Table des classes"

_columns = {

'nomc': fields.char('Nom de la classe',required=True),

'numg_ids': fields.one2many('gestion.groupe','classe_id','Groupes'),

'numm_ids': fields.one2many('gestion.matiere','classe1_id','Matieres'),

'somme_coef':

}

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.one2many('gestion.note.matiere','asso1_id','Matiere'),

}

0
Prakash Sharma
On 5/6/16, 3:47 PM

try this code:

    def _get_sum_coef(self, cr, uid, ids, name, args, context=None):
res = {}

for line in self.browse(cr, uid, ids, context=context):

sum=0
for numm_id in line.numm_ids:
sum+=numm_id.coef
           res[line.id] = {'somme_coef':sum}
return res

'somme_coef':fields.function(_get_sum_coef, string='Sum of Coef', type='integer'),

i already did this function but its not working

hamza
on 5/7/16, 6:32 PM

put logger/warning before return and tell me the content of res

webkul, Prakash Sharma
on 5/8/16, 4:59 AM

i'm actually making a qweb page and when i'm trying to print the result of the variable somme_coef it's empty

hamza
on 5/8/16, 6:39 AM

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.

Register

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)

Stats

Asked: 5/6/16, 11:41 AM
Seen: 488 times
Last updated: 5/6/16, 3:47 PM