2017-02-27 102 views
0

由於我將一些v7模塊遷移到v10社區,我仍然面臨一些錯誤和挑戰,例如,這是一個嚮導,查找大桶:TypeError:update_info()至少需要4個參數(給出2個參數) - Odoo v10社區

from odoo import api, fields, models 

class UpdateInfoPartner(models.TransientModel): 
_name = 'update.info.partner' 

def update_info(self, cr, uid, ids, context=None): 

    context = context or {} #dict(self._context or {}) 
    seniat_url_obj = self.pool.get('seniat.url') 
    self.env.cr.execute('''SELECT id FROM res_partner WHERE vat ilike 'VE%';''') 
    record = self.env.cr.fetchall() 
    pids = [item[0] for item in record] 
    seniat_url_obj.connect_seniat(self.env.cr, uid, pids, context=context, 
            all_rif=True) 
    return{} 

但每次我嘗試運行此方法時,它拋出我:

Traceback (most recent call last): 
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/http.py", line 638, in _handle_exception 
return super(JsonRequest, self)._handle_exception(exception) 
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/http.py", line 675, in dispatch 
result = self._call_function(**self.params) 
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/http.py", line 331, in _call_function 
return checked_call(self.db, *args, **kwargs) 
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/service/model.py", line 119, in wrapper 
return f(dbname, *args, **kwargs) 
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/http.py", line 324, in checked_call 
result = self.endpoint(*a, **kw) 
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/http.py", line 933, in __call__ 
return self.method(*args, **kw) 
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/http.py", line 504, in response_wrap 
response = f(*args, **kw) 
File "/home/kristian/odoov10/odoo-10.0rc1c-20161005/odoo/addons/web/controllers/main.py", line 866, in call_button 
action = self._call_kw(model, method, args, {}) 
File "/home/kristian/odoov10/odoo-10.0rc1c-20161005/odoo/addons/web/controllers/main.py", line 854, in _call_kw 
return call_kw(request.env[model], method, args, kwargs) 
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/api.py", line 681, in call_kw 
return call_kw_multi(method, model, args, kwargs) 
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/api.py", line 672, in call_kw_multi 
result = method(recs, *args, **kwargs) 
TypeError: update_info() takes at least 4 arguments (2 given) 

過這種錯誤的之前,Python,但我看不到很好的這種方法。

任何想法?

任何想法?

回答

1

可能這可以幫助你:

from odoo import api, fields, models 

class UpdateInfoPartner(models.TransientModel): 
_name = 'update.info.partner' 

def update_info(self): 

    context = dict(self.env.context or {}) 
    seniat_url_obj = self.env['seniat.url'] 
    self.env.cr.execute('''SELECT id FROM res_partner WHERE vat ilike 'VE%';''') 
    record = self.env.cr.fetchall() 
    pids = [item[0] for item in record] 
    seniat_url_obj.connect_seniat(self.env.cr, self.env.uid, pids,context=self.env.context, all_rif=True) 
    return{} 
相關問題