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

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'.




Awatar
Odrzuć
Autor Najlepsza odpowiedź

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​
Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
2
cze 22
4326
2
cze 18
5901
2
lis 16
13418
2
lut 24
12374
0
paź 23
2727