0
我對OpenERP的V7此嚮導:NameError:全局名稱「CR」沒有定義 - 從遷移到Odoov7 Odoov10
class UpdateInfoPartner(models.TransientModel):
_name = 'update.info.partner'
def update_info(self):
context = dict(self._context or {})
seniat_url_obj = self.pool.get('seniat.url')
cr.execute('''SELECT id FROM res_partner WHERE vat ilike 'VE%';''')
record = cr.fetchall()
pids = [item[0] for item in record]
seniat_url_obj.connect_seniat(pids, 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)
File "/home/kristian/odoov10/gilda/l10n_ve_fiscal_requirements/wizard/update_info_partner.py", line 14, in update_info
cr.execute('''SELECT id FROM res_partner WHERE vat ilike 'VE%';''')
NameError: global name 'cr' is not defined
我知道這個方法來調用queries
是在新的API obslete,但我怎麼能代替這個在V10?它不完全像v8
任何想法?
'cr'應持光標到數據庫。你只是沒有設置它在任何地方使用。你用'_cr'還是'self.env.cr'來試試?因爲我不熟悉openerp,所以我在黑暗中敲擊。 – bosnjak
嗨,是的,我解決了它與selv.env.cr – NeoVe
要回答我自己的問題,謝謝 – NeoVe