İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
14884 Görünümler

Hello,

I want to find a records according to search method. These records should satisfy 2 criterias.

Can i use the search method as follows : 

rec = self.env['Module.class1'].search(['&',('id', '=', self.id),('pid','=',self.pid)])
Avatar
Vazgeç
En İyi Yanıt

Hi Zak,

You can do it like this ,

rec = self.env['Module.class1'].search([('id', '=', self.id),('pid','=',self.pid)])


Thanks

Avatar
Vazgeç
Üretici

Thank you Niyas, Search return a list of records, how i can get only one record ?

Search method returns all those records which satisfies the given criteria, you can use a for loop and can iterate it like this,

search_rec = self.env['Module.class1'].search([('id', '=', self.id),('pid','=',self.pid)])

for rec in search_rec:

print rec

Üretici

You can't directly get a record without using for ?

Try like this,

rec = self.env['Module.class1'].search([('id', '=', self.id),('pid','=',self.pid), limit=1])

Try like this,

rec = self.env['Module.class1'].search([('id', '=', self.id),('pid','=',self.pid)], limit=1)

Üretici

Thank you sir