hi all
in a learning context, I wanted to test the filtering and sorting functions, but I had some problems, the code below
car_car.py Model (My car mode)
from odoo import models,fields
class Car(models.Model):
_name="car.car"
_description = "Car models"
name=fields.Char(string="Car")
carpooling_ids = fields.One2many("carpooling.carpooling",'car_id',string="Carpoolings")
brand=fields.Char(string="Brand")
the functions are located in carpooling.carpooling model.
@api.onchange('car_id')
def on_change_car_id(self):
cars = self.env['car.car'].search([]).sorted(key=lambda car: car.name)
print(cars)
the function above when fired raise error below
error TypeError: '<' not supported between instances of 'str' and 'bool'
the name field is of type Char (string)
in the same way
@api.onchange('car_id')
def on_change_car_id(self):
cars = self.env['car.car'].search([]).filtered(lambda car: "skoda" in car.name)
print(cars)
i am getting following error
TypeError: argument of type 'bool' is not iterable
I am using Odoo 17 and python 3.12, whats the wrong with my code, everything seems ok ?