Hello,
I am looking for a way to set a dynamic filter on the order lines in a tree view, so that the lines are filtered depending on a field on the parent order. I tried to work with dynamic domains, but when I do that I get a warning in the console:
odoo.models: onchange method SaleOrder.onchange_active_so_section returned a domain, this is deprecated
Also the list isn't filtered, all the lines stay visible. What is the correct way to do this in odoo14?
Here is my code:
class SaleOrder(models.Model):
_inherit = 'sale.order'
""" FIELDS """
active_so_section_id = fields.Many2one('sale.so_section', string="Active Section")
@api.onchange('active_so_section_id')def onchange_active_so_section(self):The domain I get from this onchange function is like:
domain = {'domain': {'order_line': [('id', '=', self.active_so_section_id.order_line_id.id)]}}
return domain
{'domain': {'order_line': [('id', '=', 67)]}}
see this Return Dynamic Domain For Field In Odoo || Domain Based On Another Field In Odoo || Web Domain Field
https://www.youtube.com/watch?v=dq5Vtj_pwuI