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
964 Widoki
@api.depends('category_id')
def compute_duration_display(self):
if self.category_id == 1:
self.number_of_days_display = 10
elif self
.category_id == 2:
self.number_of_days_display = 10
elif self
.category_id == 3:
self.number_of_days_display = 15
elif self
.category_id == 4:
self.number_of_days_display = 20

i tried this code but iam getting error.

Awatar
Odrzuć
Autor

Thanks for your answer.

Then how can i compare without using id's?

Najlepsza odpowiedź

Hi,

If the category_id is many2one field and if you need to perform comparison using ID, then you have to change self.category_id to self.category_id.id


Also comparison using the hard codes id's is not a good practice.


Thanks & Regards

Walnut Software Solutions

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
cze 25
1800
3
lip 25
3397
1
maj 25
1543
1
maj 25
1804
4
maj 25
2927