Advertisement
tosink

Dossie Server Action

Mar 21st, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.17 KB | None | 0 0
  1. # Available variables:
  2. #  - time, datetime, dateutil, timezone: Python libraries
  3. #  - env: Odoo Environement
  4. #  - model: Model of the record on which the action is triggered
  5. #  - record: Record on which the action is triggered if there is one, otherwise None
  6. #  - records: Records on which the action is triggered if there is one, otherwise None
  7. #  - log : log(message), function to log debug information in logging table
  8. #  - Warning: Warning Exception to use with raise
  9. # To return an action, assign: action = {...}
  10.  
  11. action_lines = env['project.task.action.line'].search([('dossie_id','=',record.id),('state','=','i')])
  12. action_lines.write({'state':'c'})
  13.  
  14. stage = env['project.task.type'].search([('name','=','Cancelado')], limit=1)
  15.  
  16. for action_line in action_lines:
  17.     action_line.task_id.write({'stage_id':stage.id})
  18.  
  19.  
  20. #and add a new action line with name Validar cancelamento in all active tasks
  21. tasks = env['project.task'].search([('stage_id.closed','=',False),('dossie_id','=',record.id)])
  22. action_id = 24 # PLEASE MANUALLY PICK THE ACTION ID FROM MODEL    
  23.  
  24. if tasks:
  25.     for task in tasks:
  26.         env['project.task.action.line'].create({'task_id':task.id, 'action_id':action_id})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement