Hi, Omer
By default in Odoo you can't add filters for related or computed fields. So in order to achieve that part you need to add "store=True" attribute inside the field like given below,
warehouse_id = fields.Many2one('stock.warehouse',string='Warehouse',related='product_tmpl_id.warehouse_ids', store=True)
And inside view file you can add filter and group by like below,
<record id="inherit_product_template_search_view" model="ir.ui.view">
<field name="name">product.template.search</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_search_view"/>
<field name="arch" type="xml">
<field name="name" position="after">
<field name="warehouse_id" string="Warehouse"/>
<group string="Group BY">
<filter string="Warehouse" name="group_warehouse_id" context="{'group_by':'warehouse_id'}"/>
</group>
</field>
</field>
</record>
Other than this if you want then you don't need to add warehouse_id field inside the product, You can filter it by default by warehouse/location,
Feel free to ask in case you have any confusion related to the above point.
Thanks,
Ashish Singh (Team Lead)
Webkul Software Private Limited