コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
1830 ビュー

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  


アバター
破棄
最善の回答

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:


アバター
破棄
関連投稿 返信 ビュー 活動
1
7月 25
398
1
6月 25
1031
0
5月 25
1148
2
4月 25
3141
1
2月 25
1349