Skip to Content
Menu
This question has been flagged
4 Replies
9866 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?

Avatar
Discard
Author

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

Author Best Answer

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)

Avatar
Discard
Best Answer

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

Avatar
Discard
Best Answer

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.

Avatar
Discard
Best Answer

try self.cr, self.uid, 

Avatar
Discard
Related Posts Replies Views Activity
7
Sep 20
7300
1
Nov 17
3945
0
Nov 16
3945
1
Jan 24
32230
3
Dec 15
6661