Community mailing list archives

community@mail.odoo.com

Re: Expected singleton error

by
karim.ajraam
- 06/28/2016 09:24:41
When i use the @api.one decorator, i have the same problem but i can save the model with the right values !!!!

2016-06-28 15:06 GMT+02:00 shabeer m <msg2shabeer@gmail.com>:
use  @api.one 

On Tue, Jun 28, 2016 at 5:23 PM, Karim AJRAAM <karim.ajraam@gmail.com> wrote:
Code class_b
class class_b(models.Model):
_name = 'class.b'

@api.multi
@api.depends('class_c.total')
def _get_total(self):
for rec in class_c:
            self.total_b +=  rec.total_c

total_b = fields.Float(compute='_get_total', string="Total", store=True, readonly=True)
class_a = fields.Many2many(
'class.a')
    class_c = fields.Many2many('class.c')

2016-06-28 13:43 GMT+02:00 Karim AJRAAM <karim.ajraam@gmail.com>:
Hello community,


class class_a(models.Model):
_name = 'class.a'
    @api.one
@api.depends('class_a.total_b')
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.Many2many('class.b', 'class_a')

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

@api.multi
@api.depends('class_c.total')
def _get_total(self):
for rec in class_c:
            self.total_b +=  total_c

total_b = fields.Float(compute='_get_total', string="Total", store=True, readonly=True)
class_a = fields.Many2many(
'class.a')
    class_c = fields.Many2many('class.c')

i have a ValueError Expected singleton: class_b(10, 11, 12, 13, 14, 15, 16, 17) error
Please help.


_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe




--
with regards
Shabeer M
Contact : 94 00 7 44 77 6

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe