How to do it...

To create an automated action with an event condition on tasks, follow these steps:

  1. In the Settings menu, select the Technical|Automation |Automated Actions menu item, and click on the Create button
  2. Fill out the basic information in the Automated Actions form:
    • Rule Name: Validate Closing Tasks
    • Related Document Model: Task
    • Conditions tab |When to Run: On Update
    • Action To Do: Execute several actions
  1. The on update rules allow you to set two record filters, before and after the update operation:
    • On the Before Update Filter field, click on the Edit domain button, set a valid domain expression—[('stage_id.name', '!=', 'Done')]—in the code editor, and save.
    • On the Apply on field, click on the Edit domain button, set the [('stage_id.name', '=', 'Done')] domain in the code editor, and save, as shown in the following screenshot:
  1. In the Actions tab, click on Add an item. In the list dialog, click on the Create button to create a new server action.
  1. Fill out the server action form with the following values and then click on the Save button:
    • Action Name: Validate closing tasks
    • Base Model: Task
    • Action To Do: Execute Python code
    • Python Code: Enter the following code:
if user != record.project_id.user_id:
raise Warning('Only the Project Manager can close Tasks')
    • The following screenshot shows the entered values:
  1. Click on Save & Close to save the automated action and try it out:
    1. On a database with demo data and logged in as Administrator, go to the Project menu and click on the E-Learning Integration project to open the kanban view of the tasks.
    2. Then, try dragging one of the tasks into the Done stage column. Since this project's manager is the Demo user and we are working with the Administrator user, our automated action should be triggered, and our warning message should block the change.
..................Content has been hidden....................

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