Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
2724 Vizualizări

I have a date field in a custom helpdesk ticket for a date, let's call that x_studio_warranty_end


In an integer field (call it x_studio_days_remaining_on_warranty) I want to compute how many days from TODAY that is. I.e. if the warranty end is '1/1/2024', I want my field to show '30'.




Imagine profil
Abandonează
Autor Cel mai bun răspuns

I ended up figuring it out after looking at many different places, maybe not the cleanest... 

for record in self:
if record.x_studio_warranty_end:​
​dt = datetime.datetime.now()
​dwarr = record.x_studio_warranty_end
​dwarrdt = datetime.datetime.combine(dwarr, datetime.datetime.min.time())
record['x_studio_days_remaining_on_warranty'] = (dwarrdt - dt).days​
Imagine profil
Abandonează
Cel mai bun răspuns

You can also use Studio to change the widget of your date field to "Remaining Days". 

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
2
iun. 22
4666
2
iun. 18
6166
2
nov. 16
13868
2
feb. 24
12683
0
oct. 23
3033