Hello, I was wondering if I have an object that I got trough a browse action like:
cats = self.env['product.category'].browse([1,2,3,4])
Now this object contains 4 category-lines.
Is it possible in the code to call like the category with id=4 like you can in a dictionary?
something like lines[4]?
Now I do it with a for loop, but this always takes 3 lines of code and looks sloppy.
for cat in cats:
if cat.id=4:
spec_cat = cat
or if I want the cats with the name='test',
test_cats = {}
for cat in cats:
if cat.name ='test':
test_cats[cat.id : cat]
I know you can do self.env['product.category'].search(['name', '=', 'test')]) or browse for the id search, but I got the feeling that this takes a new database action each time. In some for loops this would mean calling a database in a for loop. witch I think creates to much database actions.