Odoo Help

Welcome!

This community 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.

0

How to get current company without cr,uid?

8.0
By
Anders Wallenquist
on 6/24/14, 1:59 AM 3,548 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
1
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)

2
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.

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

try self.cr, self.uid, 

0

Ludo - Neobis

--Ludo - Neobis--
2387
| 2 2 5
Hoogvliet, Netherlands
--Ludo - Neobis--

Developer

Ludo - Neobis
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.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

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

Question tools

1 follower(s)

Stats

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