我正在尝试更新我的表单视图xml。这是我的代码:
def update_column(self,cr,uid,ids,context=None):
for id in ids:
temp=self.pool.get('deg.form').browse(cr,uid,id)
fields={'myname':temp.name,'mytype':temp.data_type}
self._columns.update(fields)
print (self._columns)
result = super(deg_form, self).create(cr,uid,{},context=None)
return result
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
res = super(deg_form,self).fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu)
objn = self.pool.get('deg.form').browse(cr, uid, 145)
if view_type=='form':
str_fields=str(res['fields'])
str_fields=str_fields[:len(str_fields)-1]+ ", 'father_name' :{'selectable': True, 'views': {},'type':'char', 'string': '"+objn.name+"', 'store': True,'size': 128}}"
res['fields']=eval(str_fields)
temp_arch="""<field name="father_name" />"""
fields_string=res['arch']
index_of_end_group=fields_string.find('</group>')
fields_string=fields_string[:index_of_end_group] + " " +temp_arch + " "+fields_string[index_of_end_group(inlove)
res['arch']=fields_string
return res
但我收到错误
AttributeError: 'unicode' object has no attribute '_type'
这是我的stacktrace:
Server Traceback (most recent call last):
File "/home/arsalan/openerp-7.0/openerp/addons/web/session.py", line 90, in send
return openerp.netsvc.dispatch_rpc(service_name, method, args)
File "/home/arsalan/openerp-7.0/openerp/netsvc.py", line 295, in dispatch_rpc
result = ExportService.getService(service_name).dispatch(method, params)
File "/home/arsalan/openerp-7.0/openerp/service/web_services.py", line 614, in dispatch
res = fn(db, uid, *params)
File "/home/arsalan/openerp-7.0/openerp/osv/osv.py", line 188, in execute_kw
return self.execute(db, uid, obj, method, *args, **kw or {})
File "/home/arsalan/openerp-7.0/openerp/osv/osv.py", line 131, in wrapper
return f(self, dbname, *args, **kwargs)
File "/home/arsalan/openerp-7.0/openerp/osv/osv.py", line 198, in execute
res = self.execute_cr(cr, uid, obj, method, *args, **kw)
File "/home/arsalan/openerp-7.0/openerp/osv/osv.py", line 185, in execute_cr
return getattr(object, method)(cr, uid, *args, **kw)
File "/home/arsalan/openerp-7.0/openerp/addons/system/myform.py", line 131, in update_column
result = super(deg_form, self).create(cr,uid,{},context=None)
File "/home/arsalan/openerp-7.0/openerp/osv/orm.py", line 4372, in create
bool_fields = [x for x in self._columns.keys() if self._columns[x]._type=='boolean']
AttributeError: 'unicode' object has no attribute '_type'
我正在尝试2天,现在我没有任何想法。任何帮助或解决方案指南都非常感谢。 感谢
答案 0 :(得分:1)
self._columns
中的一个是 unicode 对象。原因是您使用错误的数据类型更新self._columns
。它保留{'field_name':openerp.osv.fields.date object}
,但在这里:
temp=self.pool.get('deg.form').browse(cr,uid,id)
fields={'myname':temp.name,'mytype':temp.data_type}
self._columns.update(fields)
您使用奇怪的值更新 _columns 。