Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
4 Odpovědi
9966 Zobrazení

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
Zrušit
Autor

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

Autor Nejlepší odpověď

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
Zrušit
Nejlepší odpověď

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

Avatar
Zrušit
Nejlepší odpověď

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
Zrušit
Nejlepší odpověď

try self.cr, self.uid, 

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
7
zář 20
7454
1
lis 17
4045
0
lis 16
4032
1
led 24
32470
3
pro 15
6768