KeyError异常,当OpenERP的进口数据(keyError, When import dat

2019-10-20 09:35发布

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'

我得到这个错误,当我在客户导入的形式。 这种形式从res_partner继承。 这是csv文件。

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格式工作正常,当我导入其他形式。 但不是在客户工作。

XML代码:

<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>

你能告诉如何清除此错误。

Answer 1:

我得到了答案。 在models.py文件中的插件/ base_import文件夹。 在103行。

我已经改变

'string':fields.get('string'),

代替

'string':fields['string']


文章来源: keyError, When import data in openerp