How to do it...

To create a Python code server action, follow these steps:

  1. Create a new server action. In the Settings menu, select the Technical | Actions | Server Actions menu item, and click on the Create button at the top of the record list.
  2. Fill out the Server Action form with the following values:
    • Action Name: Send Reminder
    • Base Model: Task
    • Action To Do: Execute Python Code
  1. In the Python code text area, remove the default text and replace it with the following code:
if not record.date_deadline: 
raise Warning('Task has no deadline!')
delta = record.date_deadline - datetime.date.today()
days = delta.days
if days==0:
msg = 'Task is due today.'
elif days < 0:
msg = 'Task is %d day(s) late.' % abs(days)
else:
msg = 'Task will be due in %d day(s).' % days
record.message_post(body=msg, subject='Reminder', subtype='mt_comment')

The following screenshot shows the entered values:

  1. Save the Server Action and click on Create Contextual Action in the top-right to make it available in the project task's More button.
  2. Now, click on the Project top menu and select the Search|Tasks menu item. Pick a random task, set a deadline date on it, and then try the Send Reminder option in the More button.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset