title: Odoo Filter many2one field on load
body: <p>In my module I have a many2one field to select workers for a particular task. According to the requirement that field should only display the workers in the current user's department. Simply this is the code,</p>
  
  <pre><code> _columns = {
      'employee_id': fields.many2one('hr.employee', 'Employee'),
  }
  </code></pre>
  
  <p>My problem is how to perform such filteration for a field on load? I tried using functional field in a domain in view xml. but It seems functional field gets its value when saving the particular record. </p>
  
  <p>Also I tried adding domain to the field itself, here get_current_user_department is a function returns the department id</p>
  
  <pre><code>_columns = {
      'employee_id': fields.many2one('hr.employee', 'Employee',domain=[('department_id.id','=',get_current_user_department)]),
  }
  </code></pre>
  
  <p>This generates following error,</p>
  
  <p>TypeError:  is not JSON serializable</p>
  
  <p>Any suggestion to make this work? Thanks </p>