Odoo Help

6
3
Emipro
On 12/22/14, 2:35 AM

@Miftah

under the _defaults you can write the following code

_defaults={

'salesman':lambda self, cr, uid, ctx=None: uid

}

hope this helps !!

In the 8.0 API this would be something like this: salesman = fields.Many2one( string="Salesman", comodel_name='res.users', default= lambda self: self.env.user.id )

Rubén Cabrera
on 11/16/15, 4:42 PM
2
Ivan
On 12/22/14, 4:57 AM

Why don't you take a look at sale.order model from odoo/addons/sale/sale.py.  It has user_id defined which - AFAIK - mimics what you need.  It uses _default as well as @Emipro had suggested.

0
Ankit H Gandhi(AHG)
On 9/19/18, 8:41 AM

Hello,

You can use below code.

context = self._context

current_uid = context.get('uid')

user = self.env['res.users'].browse(current_uid)

Hope this help you.

Best Thanks,

Ankit H Gandhi.

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 12/22/14, 2:18 AM
Seen: 13061 times
Last updated: 9/19/18, 8:41 AM