Skip to Content
Menu
This question has been flagged
2 Replies
3297 Views

on odoo 8 i try to execute this action:


@api.onchange('projetbc_ligne_ids')

def onchange_evalID(self):

self.test= self.projetbc_ligne_ids.produit.id

query = "SELECT sum(quantite) FROM projet_bc_ligne where produit = %s"

self.env.cr.execute(query, (tuple(self.projetbc_ligne_ids.produit.id),))  

self.projetbc_ids.quantite_encoure = self.env.cr.fetchone()[0]


i get this error : TypeError: 'int' object is not iterable some ideas ?

Avatar
Discard
Author Best Answer

hi MouBou

Exactly 'projectdbc_ling_ids' is a many2one contain details of  order line  with field named quantity ,  and i have an other many2one 'projectdbc_ids' contain the order line and also with quantity field (the sum of quantity.projectdbc_ling_ids for each product ) , so i want for each line on order.line get the sum of quantity  for each product.

 

Avatar
Discard
Best Answer

Hello Najlae , 

i assume you have an one2mnay or many2many field and you want to calculate total quantities ? it can be done without sql query.

note : @api.onchange ('projedbc_ling_ids') dosen't work if 'projectdbc_ling_ids' is an one2many or many2many field.

if you can explain more what you want to achieve we can help you.

Avatar
Discard