How to Assign User's Manager

Most of the incidents that occur in daily work of employees will be one way or another related to their managers. Let's create an assignment policy and set up the request route to assign at a certain stage manager of the user who submitted the request.

Assignment policy is a set of rules for assignment a responsible person.

Model is a set of fields that describe an object. Each object has its own set of fields and, accordingly, records.

Assignment policy allows you to select required user based on the model and use this data for assigning a responsible person.

Let's Configure A New Assignment Policy

The assignment policy settings are located on the Rules page. Click Rules from the left menu and select Assignment policies.

When creating an assignment policy, we have no way to immediately select the manager of the person who submitted the request. To create a policy that links to different fields of different models, you can use several related policies. This way you can get the required record step by step and return its value to the original policy.

Let's divide the creation of this assignment policy on stages and create the necessary related policies one by one.

  1. We need to apply the assignment policy to the user who created the request. So we creating the policy based on the Request model and selecting the field of the user who created this request - Created by (request.request). This policy will call another related policy.
  2. The second related policy will be created based on the Users model. Here, we are able to select the user's employee to later identify his manager. Select the Related employees (res.users) field. This policy will call the next one.
  3. Next policy will be created based on the Employee model. Here we will define user employee's manager - the Manager (hr.employee) field. Now we need to create another policy that will select the user that is in the manager field. Let's create another related policy.
  4. The final assignment policy will also be created based on the Employee model. The rule type of this policy is User field and it selects the user that is written in the selected field - User (hr.employee). Since the previous policy that triggering this one applies to the manager field, we will thus get the user who is the manager.

For better understanding we can start creating the required assignment policy from the end.


To begin, we will create the assignment policy that will choose the user from the selected field of the Employee model.

On the assignment policies page, click Create to create a new policy.

On the form that opens, do the following:

  1. Enter the policy name.
  2. Select the model Employee.
  3. To create assignment policy rules, click Rules. This will save the created policy.
  4. On the rules page, click Create to create a new rule and fill out the form.
  5. In the Type field, select User field.
  6. In the Assign User Field field, select User (hr.employee).
  7. Save the rule by clicking Save.

Now let's create the policy that will get the manager field from the Employee model.

  1. On the policies page, click Create.
  2. Enter the policy name, select the Employee model.
  3. Click Rules to create an assignment policy rule.
  4. Click Create to create the rule.
  5. Enter the rule name.
  6. Select the type Related policy.
  7. In the Assign Related Policy Field, select Manager (hr.employee).
  8. In the Assign Related Policy field, select the previously created policy (in our case - User - employee).
  9. Save the rule.

Now we will create an assignment policy in which we can select an employee whose manager we chose.

  1. On the policies page, click Create.
  2. Enter the policy name, select the Users model.
  3. Click Rules to create an assignment policy rule.
  4. Click Create to create a rule.
  5. Enter the rule name.
  6. Select the type Related policy.
  7. In the Assign Related Policy Field, select Related employees (res.users).
  8. In the Assign Related Policy field select the previously created policy (in our case - Employee manager).
  9. Because there may be several employees, you need to specify which entry from the field will be selected. To do this, in the Choice type field, select First (the first entry in this field will be selected).
  10. Save the rule.

Finally, we can create an assignment policy that will select the user who created the request. This policy will be created based on the Request model.

  1. On the policies page, click Create.
  2. Enter the policy name, select the Request model.
  3. Click Rules to create an assignment policy rule.
  4. Click Create to create a rule.
  5. On the rule form, enter the rule name.
  6. Select the type - Related policy.
  7. In the Assign Related Policy Field, select Created by (request.request).
  8. In the Assign Related Policy field select the previously created policy (in our case - User's manager).
  9. Save the rule.

Test the Created Policy

Note. To test this policy, the HR application need to be installed and the structure of the company must be configured. In our case, the request is submitted by the administrator who has a manager configured with the HR app.

To check the assignment policy, click Test on the policy form.

On the form that opens:

  1. In the Policy field, select the created assignment policy (we select Manager of the user who created the request).
  2. In the Object ID field, select the object on which to test the policy. In our case this is a request that was created by the administrator.
  3. Click Test.

At the bottom of the window, you can see the overall result of testing (the Result Get and Result Convert fields). The result is returned as a dictionary (from python programming language).

Below you can see an Assign Debug Log. It displays the result of testing each rule of each policy step by step.

Set Up Automatic Assignment

Now let's set up the request route so that at the certain stage the manager is automatically assigned. In our case: set up Simple Request to automatically assign the manager of the user who created the request on the route from Draft to Sent.

Make sure that the following module is installed:

Click Requests in the main menu on the left. Then click Configuration -> Types.

Select the type of request where you want to set up automatic assignment.

On the request type form, click Routes.

Select the route that the assignment should take. On the route form, click Actions.

On the actions page, click Create and fill out the form:

  1. Enter the action name.
  2. Select the type of action - Assignment.
  3. Click the Assign tab, select the Policy Assign Type. Next to the Assign policy field select the created assignment policy.
  4. Click Save.

Now, when Simple Request moves along the route from the Draft to Sent stage, the manager of the user who submitted the request will be automatically assign as a responsible person.