Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
1995 Widoki

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  


Awatar
Odrzuć
Najlepsza odpowiedź

Hi Emman

this is the domain you are looking for: 

domain="[('x_studio_species','=',x_studio_species),('x_studio_alpha','=',True)]" 

and you have to write it on line 19: In the x_studio_alpha_new field 

you have to add it like this:


Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
2
sie 25
2403
1
lip 25
908
1
sie 25
1151
0
maj 25
1344
2
kwi 25
3566