我有这个方法,这是一个按钮:
res.partner
它应该返回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 65, in search_partner_seniat
self.write(res)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/models.py", line 3518, in write
vals.pop(field, None)
AttributeError: 'bool' object has no attribute 'pop'
的NIF,每次点击它时都会返回它,它会抛出这个:
if self.env['res.partner'].check_vat_ve(vat):
res = self.env['seniat.url']._dom_giver(vat)
self.write(res)
错误来自:
@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
我不知道这两个模型是否可能是原因,我记得他们在合作伙伴身上工作得很好:
seniat_url
在@api.multi
def _dom_giver(self, vat):
""" Check and validates that the vat is a passport,
id or rif, to send information to SENIAT and returns the
partner info that provides.
"""
#if context is None:
#context = {}
name = ''
url_seniat = ''
url_obj = self.search([], limit=1) #self.browse(self.search([]))#[0] #(cr, uid, self.search(cr, uid, []))[0]
#url1 = url_obj.name + '%s' %(value or '')
#url2 = url_obj.url_seniat + '%s' %(value or '')
if url_obj.name:
name = url_obj.name
if url_obj.url_seniat:
url_seniat = url_obj.url_seniat
url1 = name + '%s'
url2 = url_seniat + '%s'
vat = self._validate_rif(vat) #cr, uid, vat, context=None
if vat:
return self._get_rif(vat, url1, url2) #cr, uid, vat, url1, url2, context=context
else:
return False
:
(SELECT SUM(ChildName) FROM Child SA WHERE SA.Name=A.Name AND SA.Health_Status=1 AND SA.Parrent_ID IS NOT NULL) AS Present_CHILD
(SELECT SUM(LATE_COMING_CHILD) FROM LATE_COME SB WHERE SB.Name=A.Name) AS LATE_CHILD
有什么想法吗?
这些是从v8迁移到v10社区的方法。
答案 0 :(得分:1)
在写入时,您应该定义要将值写入的字段。 所以res必须是字典。当您从方法调用中替换其他字典(如False)时,它将无法将其写为字典。
我建议您使用-ErrorAction Stop
)
替换' dom'使用您要设置的变量
如果结果也可能是dict,您可以使用以下内容:
res.update({'dom' : self.env['seniat.url']._dom_giver(vat) }
答案 1 :(得分:0)
res可能为False。在调用write方法之前,您应该检查res是否为False。