Search code examples
odooodoo-8odoo-9

TypeError: 'bool' object has no attribute '__getitem__' Odoo


What is wrong with my code? I trying to do a search on product.pricelist and find all pricelists with priority boolean checked.

class ProductPricelist(models.Model):
    _inherit = 'product.pricelist'

    priority = fields.Boolean('Priority')


pricelists = self.env['product.pricelist'].search(['priority', '=', True])

TypeError: 'bool' object has no attribute '__getitem__'

Solution

  • The syntax is wrong. You should have your search argument as a list of tuples.

    pricelists = self.env['product.pricelist'].search([('priority', '=', True)])