1
votes

I'm new to Odoo. I was searching how can I make search filter in one model from fields from other model? Is it possible? I saw that search filters are made from data one model.

For example I have:

class stock_quant(models.Model):
    _inherit = "stock.quant"

and

class product_template(models.Model):
    _inherit = "product.template"

And in stock_quant view I want filter product by product_template data. How can I do that?

Thank you in advance!

1
when asking Odoo questions, it's a good idea to mention the Odoo version you're using, because this can change the answer.gurney alex

1 Answers

0
votes

if you have a relation chain from ModelA to ModelB then you can use it in the first element of the domain.

In your example, you should be able to use:

self.env['stock.quant'].search(
    [('product_id.product_tmpl_id.field_name', '=', some_value)]
)