跳至内容
菜单
此问题已终结
4 回复
10022 查看

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?

形象
丢弃
编写者

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

编写者 最佳答案

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)

形象
丢弃
最佳答案

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

形象
丢弃
最佳答案

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.

形象
丢弃
最佳答案

try self.cr, self.uid, 

形象
丢弃
相关帖文 回复 查看 活动
7
9月 20
7586
1
11月 17
4209
0
11月 16
4095
1
1月 24
32717
3
12月 15
6893