Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
2425 Lượt xem

Hello, I'm using Odoo 17.2 online (so no direct access to code).

I'm creating a Scheduled Action for status updates on projects: 

every run, the automation should check all the projects that are not in cancelled or done statuses and update their realted project.update field base on 2 conditions:

  1. if the "remaining days" are 0 or 1 -> Set the project state update state to "At Risk" 
  2. if the "remaining days" are Set the project state update state to "Off Track" 

Where remaining days = Project.date - today() in days

My Dilemma: 

I can't calculate the "Remaing Days" value. I've already tried several python constructs but they gives me always errors. Is there an explanation document on how to use datetime date interval functions inside Odoo online (or Odoo Studio let's say) ?


Thanks in advance for the help

LucaB.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

# Get today's date

today = datetime.date.today()

and to calculate the remaining days, you can loop through the projects and calculate it (try this I'm not sure)

remaining_days = (project.date - today).days

then Update the project status based on the condition

Ảnh đại diện
Huỷ bỏ
Tác giả

Thanks Sayed. This works!

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 12 22
4672
2
thg 10 24
1231
2
thg 12 20
5275
3
thg 6 25
871
1
thg 7 25
1191