Reputation: 55
<record id="hr.open_view_employee_list_my" model="ir.actions.act_window">
<field name="name">Search Filter</field>
<field name="context">{"search_default_employee_id": #}</field>
</record>
I want to replace # with the current user's employee_id so that everytime I go to Employee app the default search will automatically search for current's user employee ID.
I have tried replacing # with context.get(employee_id) but it doesn't work. If anyone can help it'll be great
Upvotes: 0
Views: 195
Reputation: 716
you can set a default
to get the employee id
def _get_employee_id(self):
employee_rec = self.env['hr.employee'].search([('user_id', '=', self.env.uid)], limit=1)
return employee_rec.id
employee_id = fields.Many2one('hr.employee', string="Employee", default=_get_employee_id, readonly=True, required=True)
<record id="hr.open_view_employee_list_my" model="ir.actions.act_window">
<field name="name">Search Filter</field>
<field name="context">{"search_default_employee_id": employee_id}</field>
</record>
Upvotes: 1
Reputation: 1668
You could use user.id
in XML to get the current user loggedin.
Upvotes: 0