Odoo Help

0

0
4 Antwoorden
1
Avatar

Mitul Shingala India

--Mitul Shingala--
5305
| 6 4 9
Vadodara, Gujarat, India
--Mitul Shingala--

Odoo Developer

Mitul Shingala India
07-02-19 01:21

Hello,

in your code product_id is many2many field. and into method line: i.product_id.price, you get the multiple product ids. that's why you get singleton error.make below change into your code:

@api.onchange('product_id')
def count(self):
    for i in self:
        total = 0
        for prod in i.product_id:
            total += prod.price
        i.total = total
0
Avatar

Dhaval Desai India

--Dhaval Desai--

807
| 2 1 4
Gandhinagar, India
--Dhaval Desai--

Senior Odoo Developer

Dhaval Desai India
13-02-19 01:51

Hi Ruturaj,

ValueError: Expected singleton: product1.product1(2, 4)  it means product_id return multiple records you can not directly assign values.

Example:

@api.onchange('product_id')
def count(self):
    for i in self:
        total = 0
        for p in i.product_id:
            total += p.price
        i.total = total
Thank You.
0
Stel een vraag
Schrijver
Blijf op de hoogte
1 volger(s)
Over deze 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