Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
4 Odpowiedzi
9975 Widoki

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?

Awatar
Odrzuć
Autor

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

Autor Najlepsza odpowiedź

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)

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Najlepsza odpowiedź

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.

Awatar
Odrzuć
Najlepsza odpowiedź

try self.cr, self.uid, 

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
7
wrz 20
7479
1
lis 17
4063
0
lis 16
4033
1
sty 24
32479
3
gru 15
6773