I have this composite sql statement that i want to put it in a field's domain, how do i do that
SELECT * FROM custom_product INNER JOIN custom_branch_line ON custom_product.id = custom_branch_line.product_id INNER JOIN custom_user_line ON custom_branch_line.branch_id = custom_user_line.branch_id where custom_user_line.user_id = %s" % self.env.user.id
I managed to do it using the following code
branch_product_ids = fields.Many2one(comodel_name="custom.product", string="Product",
domain="[('branch_line.branch_id.user_lines.user_id','=', user_id)]")
Here's the explanation:
model "custom.product" has a one2many field "branch_line" connects it to model "custom.branch.line"
model "custom.branch.line" has a many2one field "branch_id" which connects it to model "custom.branch"
model "custom.branch" has a one2many field "user_lines" which connects it to model "custom.user.line"
model "custom.user.line" has a field user_id