Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
945 Visualizzazioni
@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.

Avatar
Abbandona
Autore

Thanks for your answer.

Then how can i compare without using id's?

Risposta migliore

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

Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
1
giu 25
1773
3
lug 25
3378
1
mag 25
1526
1
mag 25
1778
4
mag 25
2914