Hi Guys,
Need help. Trying to set a dynamic field for capturing the current logged in user to be used in a view.
I have tried both a computed field and by using default attribute and unable to set the record with the currently logged in user.
Code:
cur_user = fields.Many2one('res.users','Approved By', default=_get_user_id)
@api.one
def _get_user_id(self):
return self.env.uid
I have also tried setting the uid directly in the default attribute as follows:
cur_user = fields.Many2one('res.users','Approved By', default=lamba self:self.env.uid)
and various other variations on this. but no luck.
I have a field displayed in the view which does not show up the user name:
Current User: <field name="cur_user" />
Any help would be appreciated.
Regards,
Damien