I want to search records of one2many field that depends on another fields.
here my code,
Parent class:
class SaleOrder(models.Model):
_inherit = 'sale.order'

customer_product_ids = fields.One2many('product.product',
order_line = fields.One2many('sale.order.line', 'order_id')
Child class:
class SaleOrderLine(models.Model):
_inherit = 'sale.order.line'

order_id = fields.Many2one('sale.order')
product_id = fields.Many2one('product.product')


[('id', 'in', [rec.id for rec in parent.customer_product_ids])]

By default, a customer can see all the products defined.
In my case, I need to filter the products depends on customer selected.
Each customer can have different list products or if they didn't categorize they can see all the products.
I tried the code above but got error:
Uncaught Error: Expected "]", got "(name)"
I guess the error come from this code:
[('id', 'in', [rec.id for rec in parent.partner_product_ids])]
my question,
is it possible to do python loop comprehension like the code above (within view)?
Thank you.

View Solution