Ir al contenido
Menú
Se marcó esta pregunta
4 Respuestas
9874 Vistas

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
Descartar
Autor

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

Autor Mejor respuesta

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
Descartar
Mejor respuesta

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

Avatar
Descartar
Mejor respuesta

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
Descartar
Mejor respuesta

try self.cr, self.uid, 

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
7
sept 20
7306
1
nov 17
3951
0
nov 16
3970
1
ene 24
32246
3
dic 15
6664