我正在继承res.partner
:
class ResPartner(models.Model):
_name = 'res.partner'
_inherit = 'res.partner'
@api.model
def check_vat_ve(self, vat): #, context=None
""" Check Venezuelan VAT number, locally called RIF.
RIF: JXXXXXXXXX RIF VENEZOLAN
IDENTIFICATION CARD: VXXXXXXXXX
FOREIGN IDENTIFICATION CARD: EXXXXXXXXX
"""
#if context is None:
#context = {}
if re.search(r'^[VJEGP][0-9]{9}$', vat):
return True
if re.search(r'^([VE][0-9]{1,8}|[D][0-9]{9})$', vat):
return True
return False
正如您所看到的,有一个名为chack_vat_ve
的方法,它在res.partner
对象上声明。
现在,我有另一个(向导)方法,用于按钮:
@api.multi
def search_partner_seniat(self):
""" Check vat of the partner and update iva rate
"""
self.ensure_one()
vat = self.vat.upper()
res = {
'name': _('The requested contributor does not exist'),
'vat_subjected': False,
'vat': vat,
'wh_iva_agent': False,
'wh_iva_rate': 0.0
}
if 'VE' in vat:
vat = vat[2:]
# assumption: both methods in new api style
if self.env['res.partner'].check_vat_ve(vat):
res = self.env['seniat.url']._dom_giver(vat)
self.write(res)
每次我点击它,都会引发我的注意:
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/search_info_partner_seniat.py", line 63, in search_partner_seniat
if self.env['res.partner'].check_vat_ve(vat):
AttributeError: 'res.partner' object has no attribute 'check_vat_ve'
我几乎可以肯定,向导方法存在一些错误,因为我正在迁移这些模块,从v8迁移到v10社区,它们仍然是一种错误。
有什么想法吗?
答案 0 :(得分:2)
您可以尝试删除 _name =' res.partner' 属性,因为这似乎没必要,然后告诉我们。