This question has been flagged
1 Reply
2873 Views

I am using odoo 10 enterprise . I am trying to set default value as logged in user, i know how to do that 

https://www.odoo.com/forum/help-1/question/how-to-assign-the-logged-in-user-as-a-default-value-45339

above link also describe this but in addition to this i want to set a condition that i want to set this manually from default if the logged in user is admin or suppose some specific user otherwise user will select from drop-down while creating record in form view.

Note : I have created field as many2one and added filter on that drop-down so that filtered user show-up only in drop-down

Avatar
Discard
Best Answer

If you want to give default value based on a condition use 

your_field = fields.Many2one('res.user', string="your field", default=any_function)

then in the function

def any_function(self):
if your group in self.env.user.groups_id :


Avatar
Discard