Advertisement
rht_odoo

[QW][4143143] Taches rappel

Aug 28th, 2024 (edited)
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.59 KB | None | 0 0
  1. # Done by RHT on the 28/08/2024
  2. # Need : Have recurrent task
  3. # Task : https://www.odoo.com/odoo/project/5686/tasks/4143143
  4. # Pastebin : https://pastebin.com/sAZtiGQP
  5. for task in records:
  6.     # R1 ID --> 394
  7.     # R2 ID --> 405
  8.     # R3 ID --> 406
  9.     # RM1 ID --> 421
  10.     # RM2 ID --> 422
  11.     # RM3 ID --> 614
  12.     # if task has label R1
  13.     if 394 in task.tag_ids.ids:
  14.         label = 405
  15.         task_name = 'Rappel 1'
  16.         number_of_days = 35
  17.     # if task has label R2
  18.     if 405 in task.tag_ids.ids:
  19.         label = 406
  20.         task_name = 'Rappel 2'
  21.         number_of_days = 20
  22.     # if task has label R3
  23.     if 406 in task.tag_ids.ids:
  24.         label = 0
  25.         task_name = 'Rappel 3'
  26.         number_of_days = 12
  27.     # if task has label RM1
  28.     if 421 in task.tag_ids.ids:
  29.         label = 422
  30.         task_name = 'Rappel mensuel 1'
  31.         number_of_days = 12
  32.     # if task has label RM2
  33.     if 422 in task.tag_ids.ids:
  34.         label = 614
  35.         task_name = 'Rappel mensuel 2'
  36.         number_of_days = 9
  37.     # if task has label RM3
  38.     if 614 in task.tag_ids.ids:
  39.         label = 0
  40.         task_name = 'Rappel mensuel 3'
  41.         number_of_days = 8
  42.        
  43.     new_task = env['project.task'].create(
  44.         {
  45.             'name' : task_name,
  46.             'project_id' : task.project_id.id,
  47.             'date_deadline' : datetime.date.today() + datetime.timedelta(days=number_of_days),
  48.             'user_ids' : task.user_ids.ids,
  49.         })
  50.     if label != 0:
  51.         new_task.write(
  52.             {
  53.                 'tag_ids' :  [(4, label)] ,
  54.              })
  55.  
  56.  
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement