Community mailing list archives

Re: Expected singleton error

Omal Bastin
- 06/24/2016 07:36:52
when using @api.multi, self will have multiple records. so you need to use for loop to get each record. So instead @api.multi use is depricated i think. but in your case it will be fine

On Fri, Jun 24, 2016 at 4:32 PM, Karim AJRAAM <> wrote:
Hello community,

this is my code : 

class class_a(models.Model):
_name = 'class.a'
def _get_total(self):
       self.total_a = 0
       for i in self.class_a:
self.total_a += i.total_b

    total_a = fields.Float(compute='_get_total', string="Total", store=True)
    class_a = fields.One2many('class.b', 'class_a')

class class_b(models.Model):
_name = 'class.b'

def _get_total(self): = self.qte * self.prixu

qte = fields.Float('Quantite', required=True)
prixu = fields.Float('Prix U')
total_b = fields.Float(compute='_get_total', string="Total", store=True, readonly=True)
class_a = fields.Many2one('class.a')
i have this error : ValueError Expected singleton: class_b(56, 57, 55)
Please help.

Post to:

Omal Bastin