I am always getting ValueError: Expected singleton: this error Can I get to undestand what the main solution to it pleaase
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
1
Reply
2069
Views
Hi Loomoni Morwo ,
Recordset with only one record is called a singleton ,
>>> partner = self.env['res.partner'].search([('name', 'like', 'Odoo')])
>>> print(partner)
res.partner(72,) // recordset with single record
>>> print(partner.name)
Odoo
Error is because recordset contain multiple records,
>>> partner = self.env['res.partner'].search([('name', 'like', 'Odoo')])
>>> print(partner)
res.partner(72,75) // recordset with multiple record
>>> print(partner.name) // Printing recordset with multiple records , it throws singleton error
Expected singleton: res.partner(72,75)
To avoid these kind of error make sure you loop through recordset.
>>> partner = self.env['res.partner'].search([('name', 'like', 'Odoo')])
>>> print(partner)
res.partner(72,75)
>>> for rec in partner :
>>> print(rec.name)
Odoo
Odoo1
Hope it helps ,
Kiran
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up
Look this: https://www.odoo.com/es_ES/forum/ayuda-1/expected-singleton-180078