When I click on onchange if I have one record it comes perfectly,but
when I add multiple records showing error likey", line 4822, in ensure_one ValueError: Expected singleton: destination.type(4, 3)
https://prnt.sc/gq9nvw
class BaseTrade(models.Model):
_name='base.trade'
name=fields.Char('Name')
test_many2many_ids=fields.Many2many('destination.type','source_dest_rel','source_id','dest_id')
value_test=fields.Char('ABC')
@api.onchange('test_many2many_ids')
def change_type(self):
for record in self:
record.value_test=self.test_many2many_ids.value.name
class DestinationType(models.Model):
_name='destination.type'
name=fields.Char('Type')
value=fields.Many2one('details.all','Details')
class DetailsAll(models.Model):
_name='details.all'
name=fields.Char('Test')
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
3491
Views
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
Problem with the record.value_test=self.test_many2many_ids.value.name,
self.test_many2many has to be iterate over a loop,
for rec in self.test_many2many
print rec,
Do something like this
Hi Niyas..I changed like this..but getting issue...
@api.onchange('test_many2many_ids')
def change_type(self):
for record in self:
# self.ensure_one()
for rec in record.test_many2many_ids:
rec.value_test=self.test_many2many_ids.value.name
many2many will give set of records so you will need to iterate them too in order to get the value
@api.onchange('test_many2many_ids')
def change_type(self):
for record in self:
for i in record.test_many2many_ids:
record.value_test=i.value
Yeah..Absoultely..Thanks Onkar..
Thanks Noyas..