Hello, so I'm trying to learn Odoo studio, and I've encounter a question wherein I need to show the hierarchy for different animals.
Animal Hierarchy
- Add a check-box : Is an ‘Alpha’ ? (False by default)
- If FALSE, display a field in which we can choose its ‘Alpha’ (Only the ones that are alphas can be chosen)
- If TRUE, display all animals of the group that have this animal as the ‘Alpha’ BUT do not let users add animals to that list, it should not be editable.
So this is my step.
I completed this step but I don't know if im correct
- Add checkbox
- Add a many2one pointing to the animals model with invisibility condition "alpha is true" to add the alpha of the animal
- Add a One2many pointing to animals with invisilibilty condition "alpha is false" + readonly
And this part, I'm having a trouble,
- To respect the species, you will have to add a dynamic domain on the many2one field. That's only doable via the code. If you want to do it, you will have to create a random domain on the field, then go on the XML to replace it by --> domain="[('x_studio_species','=',x_studio_species)]" to specify that the species of the animal should be the same specie of the record. You can also add a domain to say that the animal should be an Alpha.
This is the AlpheNew
This is the xml view I'm trying to edit but I don't know where should I put it.
This is the code sample, https://pastecode.io/s/f8f7vsen