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
2170 Widoki

I would like to set 14 days deadline after a task change stage to specific one.

I've tried to write a python code but it says that I´ve wrong syntax (Im not a programmer)

record['date_deadline'] = time.strftime('%Y-%m-%d %H:%M:%S',time.gmtime(time.time()+14*24*3600))

Does anybody know how to fix it?


Thanks a lot!

Awatar
Odrzuć
Najlepsza odpowiedź

In Odoo, you can use the datetime module to add 14 days to the current date and set it as the deadline for a task. Here is an example of how you can do it:

import datetime

# Get the current date and time
current_datetime = datetime.datetime.now()

# Add 14 days to the current date and time
deadline_datetime = current_datetime + datetime.timedelta(days=14)

# Set the deadline for the task
record['date_deadline'] = deadline_datetime

In the code above, current_datetime contains the current date and time. We then add 14 days to it using the timedelta method of the datetime module. The resulting deadline_datetime variable contains the date and time 14 days in the future. We then set this value as the date_deadline field of the task.

You can adjust the code to suit your specific needs. For example, you can add a condition to check if the task has reached a specific stage before setting the deadline.

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
0
kwi 24
846
1
maj 25
708
0
kwi 25
686
3
lis 24
3488
1
lis 22
3335