This question has been flagged
1 Reply
1186 Views

Hello Odoo community, 

    Please help me with the python expression: I wish to program the planned start time of a task the same as the time when the kanban state of the task changed. How do I code it in automated action? Thank you

This is what I have so far:
Model: Task; Trigger: On update; Trigger field: kanban state (project.task);
Domain: Kanban state="normal"; Apply on: Kanban state = "blocked"; Action to Do: update the record
Then for field: planned start (project.task) and planned stop project task, I don't know what to choose under Evaluation type and put under value
I want the planned start date to be the day when kanban state changed, and the planned end date to be 1 day after

Avatar
Discard
Best Answer

Hi,

I hope that the planned_start_date(Planned Start Date) and planned_end_date(Planned End Date) are your custom fields which are to be updated on changing the Kanban State from normal(In Progress) to blocked(Blocked). You can use the configurations(values set for the fields in automated action) as you set already.

Model: Task; Trigger: On update; Trigger field: kanban state (project.task);
Domain: Kanban state="normal"; Apply on: Kanban state = "blocked";

Here I am using the Action to Do: Execute Python Code. So, set it and add the code below in the space for Python Code.

if records:
records.write({
# if you have planned_start_date and planned_end_date as date fields:
# 'planned_start_date': datetime.date.today(),
# 'planned_end_date': datetime.date.today() + dateutil.relativedelta.relativedelta(days=1)

# if you have planned_start_date and planned_end_date as datetime fields:
'planned_start_date': datetime.datetime.today(),
'planned_end_date': datetime.datetime.today() + dateutil.relativedelta.relativedelta(
days=1)
})

Regards

Avatar
Discard
Author

Thanks a lot! For some reasons, it doesn't work with Action to Do: Execute Python Code but work with Action to Do: update the record, though using the same python expression.