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)])
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
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)])
Hi Zak,
You can do it like this ,
rec = self.env['Module.class1'].search([('id', '=', self.id),('pid','=',self.pid)])
Thanks
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
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)
Thank you sir
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up