0
I name_search
方法でres.partner
を継承し、このクラスがあります:選択しようとしたときはIndexError:範囲外のリストインデックス - Odoo v10のコミュニティにOdooのV8
class ResPartner(models.Model):
_inherit = 'res.partner'
@api.multi
def name_search(self, name='', args=None, operator='ilike', limit=80): #cr, uid, context=None,
"""
Gets el id of the partner with the vat or the name and return the name
"""
#if context is None:
#context = {}
self.ensure_one()
args = args or []
ids = []
if len(name) >= 2:
ids = self.search([('vat', operator, name)] + args, limit=limit) #cr, uid, [('vat', operator, name)] + args, limit=limit, context=context
if not ids:
ids = self.search([('name', operator, name)] + args, limit=limit) #cr, uid, [('name', operator, name)] + args, limit=limit, context=context
return self.name_get() #cr, uid, ids, context=context
しかし、すべての時間が、私は請求書account.invoice
を作成するために行きますパートナー:それは私にこれを投げます:
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 862, in call_kw
return self._call_kw(model, method, args, kwargs)
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 668, in call_kw_multi
ids, args = args[0], args[1:]
IndexError: list index out of range
私はそのクラスにいくつかの他のメソッドを持っていますが、問題のあるものは上記のものです。
def name_search(
self, cr, uid, name='', args=None, operator='ilike', context=None,
limit=80):
"""
Gets el id of the partner with the vat or the name and return the name
"""
if context is None:
context = {}
args = args or []
ids = []
if len(name) >= 2:
ids = self.search(cr, uid, [('vat', operator, name)] + args,
limit=limit, context=context)
if not ids:
ids = self.search(cr, uid, [('name', operator, name)] + args,
limit=limit, context=context)
return self.name_get(cr, uid, ids, context=context)
任意のアイデア:
はもともと、このメソッドは、この(バージョン8日)のように見えましたか? odooで
は、非常に同じ問題をありがとう:(、I場合は、好奇心に何かをtheresのをそれを@ api.modelに変更します。それはもはや発生しませんが、請求書を作成するたびに新しいクライアントを作成しなければなりません。すでに存在するかどうかは関係ありません。res.partnerにはこのname_searchメソッドがあります元々はそれが@ api.modelだと私は質問を編集するつもりだと思う – NeoVe
あなたldは_name_searchをオーバーライドしてほとんど同じコードを使用します – Cherif
あなたのお手伝いをするかもしれません – Cherif