Skip to Content
Menu
This question has been flagged
1 Reply
1111 Views

Hi all,

so im using a service in a sale order to create a task in a project. Is there a way of using automated actions so that when i update the delivery date in a sales order the task deadline updates if that product exists on the sale order. 

At the moment im adding the delivery date and then going into project tasks and updating that to the same date. i think there must be an easier/faster way.


Also if that is a thing would it be also possible to move a task to completed when the product is delivered or whole sale order delivered.


Many thanks

Avatar
Discard
Best Answer

Hi Steven,

here is what you are searching for.

Now, whenever you update the field Delivery Date (commitment_date) on the sales order, all the tasks related to the lines of the sale order will get updated on the field deadline.

Regarding the last point, it will be somehow the same, but needs more clarification. 

Hamid - bitigloo GmbH

Avatar
Discard
Author

Thats amazing Hamid. but i do have more than one service on the sales order and more than one task so how would i do this based on product id to just update the one task.

Hey Steven,
the code will update all the tasks that are in any of the lines, not just 1 line and not just 1 task.
If you want to update all the tasks that are linked to that Sales Order and not just the lines you can do this:

for rec in records:
for task in rec.task_ids:
task.update({
'date_deadline': rec.commitment_date
})

Maybe I misunderstood what you mentioned. Maybe you can explain a little more, what is the expected behavior? And how you can distinguish for which task the deadline should get updated and for which not?

Author

so i have confused the situation.

Each sales order has 3 tasks created from 3 lines/products
Project management
Commissioning
Manufacturing

Project management has a deadline that matches the sale order delivery date
the other 2 the date is set by the engineer

using your solution i understand that all three will update to the delivery date whereas i only need the project management task to reflect that date.

does that make sense ?

ok, now I got it. A quick but sensitive way is to match it with the product_id and I would definitely use the first code in the screenshot, not the second one in the comments, but adjust it as below:

imagine the id of the product is 10. (you should check it in the product variants, not products).

for rec in records:
for line in rec.order_line:
if line.product_id.detailed_type == "service" and line.task_id and line.product_id.id == 10:
line.task_id.update({
'date_deadline': rec.commitment_date
})

the right way to do it, can be adding a new boolean field on product like "Update Deadline" and then we check this field and update the task if the product has this checkbox as True.

Author

Amazing, Thank you

Related Posts Replies Views Activity
1
Jun 23
1918
0
Jul 23
1155
2
May 23
2233
3
Apr 24
1472
1
Oct 23
1738