我有这个向导,顺便说一句,工作正常:
url1 = fields.Char(
string='URL1', size=255, required=True, readonly=False,
default=lambda s: s._get_url1(),
help='In this field enter the URL from Seniat for search the'
' fiscal information from partner')
url2 = fields.Char(
string='URL2', size=255, required=True, readonly=False,
default=lambda s: s._get_url2(),
help='In this field enter the URL from Seniat for search the'
' retention rate from partner (RIF)')
url3 = fields.Char(
string='URL3', size=255, required=True, readonly=False,
default=lambda s: s._get_url3(),
help='In this field enter the URL from Seniat for search the'
' retention rate from partner (CI or Passport)')
@api.multi
def _get_url(self): #, cr, uid, ids, context=None
""" Get seniat web page
"""
url = self.env['seniat.url']
url_ids = url.search([]) #(self.env.cr, self.env.uid, []) 2nd version url.search.self.env['seniat.url']
if len(url_ids) > 1:
url.unlink.self.env.url_ids[1:] #(self.env.cr, self.env.uid, url_ids[1:])
url_obj = self.env['seniat.url'].browse(url_ids)#= self.env['url_ids'].browse() #url.browse(self.env.cr, self.env.uid, url_ids, context=None)[0]
return url_obj #url_obj
@api.multi
def _get_url1(self): #, cr, uid, ids, context=None
url_obj = self._get_url() #(self.env.cr) # , uid, ids, context
return url_obj.name
@api.multi
def _get_url2(self): #, cr, uid, ids, context=None
url_obj = self._get_url() #(self.env.cr) #, self.env.uid, ids, context
return url_obj.url_seniat
@api.multi
def _get_url3(self): #, cr, uid, ids, context=None
url_obj = self._get_url() #(self.env.cr) #, self.env.uid, self.env.ids, self.env.context
return url_obj.url_seniat2
现在,如果我将此data
文件添加到清单中:
<?xml version='1.0' encoding='UTF-8'?>
<odoo>
<data noupdate="0">
<record id="seniat_url_2011" model="seniat.url">
<field name="name">http://contribuyente.seniat.gob.ve/getContribuyente/getrif?rif=</field>
<field name="url_seniat">http://contribuyente.seniat.gob.ve/BuscaRif/BuscaRif.jsp?p_rif=</field>
<field name="url_seniat2">http://contribuyente.seniat.gob.ve/BuscaRif/BuscaRif.jsp?p_cedula=</field>
</record>
</data>
</odoo>
它抛出了我:
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 679, in call_kw
return call_kw_model(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 664, in call_kw_model
result = method(recs, *args, **kwargs)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/models.py", line 1101, in default_get
defaults[name] = field.default(self)
File "/home/kristian/odoov10/gilda/l10n_ve_fiscal_requirements/wizard/wizard_url_seniat.py", line 41, in <lambda>
default=lambda s: s._get_url3(),
File "/home/kristian/odoov10/gilda/l10n_ve_fiscal_requirements/wizard/wizard_url_seniat.py", line 70, in _get_url3
return url_obj.url_seniat2
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/fields.py", line 860, in __get__
self.determine_value(record)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/fields.py", line 960, in determine_value
record._prefetch_field(self)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/models.py", line 3044, in _prefetch_field
result = records.read([f.name for f in fs], load='_classic_write')
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/models.py", line 2984, in read
self._read_from_database(stored, inherited)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/models.py", line 3112, in _read_from_database
cr.execute(query_str, params)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/sql_db.py", line 141, in wrapper
return f(self, *args, **kwargs)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/sql_db.py", line 218, in execute
res = self._obj.execute(query, params)
File "/home/kristian/.virtualenvs/odoov10/local/lib/python2.7/site-packages/psycopg2/extensions.py", line 129, in getquoted
pobjs = [adapt(o) for o in self._seq]
ProgrammingError: can't adapt type 'seniat.url'
这是默认数据,位于data
文件夹。
由于这是我从v8到v10的模块迁移,我不知道这是不是在数据xml上声明模型的新方法。
有什么想法吗?
答案 0 :(得分:1)
您拥有该字段的声明:
url3 = fields.Char(
string='URL3', size=255, required=True, readonly=False,
default=lambda s: s._get_url3(),
help='In this field enter the URL from Seniat for search the'
' retention rate from partner (CI or Passport)')
这是Char
类型的字段,因此需要一个字符串作为其默认值。作为默认值,您已设置:s._get_url3()
但是从_get_url3
返回的对象属于seniat.url
类型,您必须从_get_url3
方法返回一个字符串。