Odoo Help


How to get current company without cr,uid?

Anders Wallenquist
on 6/24/14, 1:59 AM 4,929 views

I override a method whats define only have self (from ir_sequence):

def _interpolation_dict(self):
         #user = self.pool.get('res.users').browse(cr, uid, uid, context=context)

         # ...

        return super(ir_sequence, self)._interpolation_dict()

I want to get current user / company / country etc

Any ideas?

No there is no context, nor any self.cr or self.uid.

Anders Wallenquist
on 6/24/14, 6:03 AM
Anders Wallenquist
On 6/24/14, 6:04 AM

I did this instead (using another method, not beautiful but working)

    def _interpolation_dict(self):
        #_logger.debug("Self %r", self.code)
        res = super(ir_sequence, self)._interpolation_dict()
        res['country'] = self.code.upper()
        return  res
    def _next(self, cr, uid, seq_ids, context=None):
        self.code = self.pool.get('res.users').browse(cr, uid, uid).company_id.country_id.code
        return super(ir_sequence, self)._next(cr, uid, seq_ids, context)

Martin Apitz
On 12/30/14, 7:26 PM

You can use self._cr and self._uid to get the pointer and the user id.

Vũ Quốc Hoàng
On 6/24/14, 4:52 AM

try self.cr, self.uid, 


Ludo - 21South

--Ludo - 21South--
| 2 2 5
Zwijndrecht, Netherlands
--Ludo - 21South--


Ludo - 21South
On 6/24/14, 3:46 AM

Is a context available? If so, try to look at that. Sometimes that has a uid as well. 

By the way, is there no cursor on self? 

For reference, open file "account_journal.py" in the account/project/report directory.

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 6/24/14, 1:59 AM
Seen: 4929 times
Last updated: 3/16/15, 8:10 AM