Skip to Content
Menu
This question has been flagged
2 Replies
14588 Views

I try to get records that  have  same name with customer created  data  with the following code.

val=self.env['res.partner'].search([('name','=',record.name)]) and it works.When I log  it using

logging.info(val) command, it shows res.partner(26,33).

These are id of same records?So,how can I get detail information of record using this id?

I try to query like

count=0

for x in val:

if x:

count=count+1

query=('SELECT *'

'FROM res_partner'

'WHERE id=x')

self.env.cr.execute(query)

logging.info("query data are")

for row in self.env.cr.fetchall():

logging.info(row[0])


But  It does not work.Thank You


Avatar
Discard
Best Answer

You should try:

val=self.env['res.partner'].search_read([('name','=',record.name)])

This will return a dict of field as key and values instead records.

Avatar
Discard
Best Answer

Search returns a recordset, see: https://www.odoo.com/documentation/11.0/reference/orm.html, yours val is a recordset too. If you use

for x in val:

x is a record from recordset. This record has id = x.id

In conclusion, your bug in ...WHERE id=x



Avatar
Discard
Related Posts Replies Views Activity
2
Jul 24
939
1
Jun 24
3560
1
Oct 23
8579
1
Oct 23
97
1
Aug 23
2192