Hi!
I have a category
model, and a subcategory
model. Subcategories have a single parent category (x_parent_category_id
), and categories can have many child subcategories.
- Companies
- Small
- Medium-sized
- Large
- Associations
- Regular non-profit
- NGOs
- Fund
- Investment fund
- Pension
- …
I have two many-to-one relationships on my customers to know their category (x_category_id
) and their subcategory (x_subcategory_id
) .
I'd like to be able to set a domain on the x_subcategory_id
relationship so that subcategories are always a child of the parent category.
So, I have trouble using a domain like [('x_parent_category_id', '=', x_category_id)]
.
It seems both Odoo Studio and the debug mode forms hate x_category_id
as a floating value here, raising a NameError
. I also naively tried self.x_category_id
unsuccessfully.
Is there any way to achieve this domain setup?
Right now, I'm checking that the field is properly set using an automation. It's a bit cumbersome and surely there's a fancier way to achieve this!
I use Odoo Online, so version 18.