تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
5213 أدوات العرض

In Odoo V11 CE, we use the 'Create a task in an existing project' option in the 'Service Tracking' field.  If a Sale Order is cancelled, we have to remember to manually archive the related Task, so that it no longer appears to assigned users etc.

Is it possible to create an automated action that will archive a Task related to a Sale Order that has been cancelled?

I'm new to Automated Actions and Python, so if someone can suggest the Python code (I'm assuming  it  will  be  necessary) to use to update the related Task, that would be very much appreciated!

Thank you.

الصورة الرمزية
إهمال
أفضل إجابة

Hi,

You can create an automated action from the settings as shown in this image:  https://ibb.co/bB5F2YM


Automated Action:

Trigger: On Update
Trigger Fields: Status

Action To Do: Execute Python Code

Python Code:

for rec in records:
if rec.state == 'cancel' and rec.task_ids:
for task in rec.task_ids:
task['active'] = False


Thanks

الصورة الرمزية
إهمال
الكاتب

thanks Niyas Raphy. I will give it a try.

الكاتب

Thanks Niyas Raphy. It works with Gregory's typo correction

أفضل إجابة

Corrected small error 'missing s' in python:

for rec in records:
if rec.state == 'cancel' and rec.tasks_ids:
for task in rec.tasks_ids:
task['active'] = False

الصورة الرمزية
إهمال
الكاتب

thanks for picking up the typo Gregory

المنشورات ذات الصلة الردود أدوات العرض النشاط
3
مارس 23
1723
1
نوفمبر 22
2839
1
مايو 21
3480
1
يونيو 23
2019
1
نوفمبر 22
7110