0
votes

I'm developing an OpenERP 7 module and I need to add a field that logs the user who created each record. How do I retrieve the current user object?

2

2 Answers

2
votes

this kind of field is already available in openerp, as create_uid and write_uid.

1
votes

In OpenERP Python code, functions generally take cr, the database pointer, and uid, the user id, as arguments. If all you need is the id of the current res.users object (for instance, to write into the one2many field), you can use uid as is. If you need to access the object (to see fields, etc.), something like:

current_user = self.pool.get('res.users').browse(cr, uid, uid, context=context)

should work.