问题
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140112_001021-py2.7.egg/openerp/osv/osv.py", line 199, in execute
res = self.execute_cr(cr, uid, obj, method, *args, **kw)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140112_001021-py2.7.egg/openerp/osv/osv.py", line 187, in execute_cr
return getattr(object, method)(cr, uid, *args, **kw)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140112_001021-py2.7.egg/openerp/addons/base_import/models.py", line 219, in parse_preview
fields = self.get_fields(cr, uid, record.res_model, context=context)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140112_001021-py2.7.egg/openerp/addons/base_import/models.py", line 116, in get_fields
cr, uid, field['relation'], context=context, depth=depth-1)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140112_001021-py2.7.egg/openerp/addons/base_import/models.py", line 116, in get_fields
cr, uid, field['relation'], context=context, depth=depth-1)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140112_001021-py2.7.egg/openerp/addons/base_import/models.py", line 103, in get_fields
'string': field['string'],
KeyError: 'string'
I am getting this error, When i import in customer form. This form inherited from res_partner. this is csv file.
id,"name"
__export__.res_partner_10,"1"
__export__.res_partner_11,"2"
__export__.res_partner_579,"abrajeethan"
__export__.res_partner_640,"Abu"
__export__.res_partner_584,"ahmekldsgjfmkp"
__export__.res_partner_469,"Anand"
__export__.res_partner_672,"aniasdftha"
__export__.res_partner_49,"Ayantasdfika"
__export__.res_partner_481,"Aasdfyantikr"
csv format is working fine, when i import other form. But not working in customer.
xml code:
<record id="extended_view_partner_tree" model="ir.ui.view">
<field name="name">Customers</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_tree"/>
<field name="arch" type="xml">
<tree string="Contacts">
<field name="client_id"/>
<field name="clientadded_date"/>
<field name="branch"/>
<field name="phone"/>
<field name="email"/>
</tree>
</field>
</record>
Can you please tell how to clear this error.
回答1:
I got answer. In addons/base_import folder at models.py file. in 103 line.
I have changed as
'string':fields.get('string'),
instead of
'string':fields['string']
来源:https://stackoverflow.com/questions/24607823/keyerror-when-import-data-in-openerp