Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
4 Replies
9990 Tampilan

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
Buang
Penulis

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

Penulis Jawaban Terbai

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
Buang
Jawaban Terbai

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

Avatar
Buang
Jawaban Terbai

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
Buang
Jawaban Terbai

try self.cr, self.uid, 

Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
7
Sep 20
7509
1
Nov 17
4093
0
Nov 16
4040
1
Jan 24
32498
3
Des 15
6796