ValueError:系统中当前没有定义此类外部ID:(OpenERP V 7.0)

时间:2013-09-29 17:38:19

标签: openerp

你好我是OpenERP的新手。我刚刚从OpenERP的官方合作伙伴处购买了视频。我在观看他们的视频时正在练习。在他们的实践中,我已经成功地完成了所有工作,但是在为他们的视频中的代码添加了一些功能后出现以下错误。


OpenERP服务器错误

Client Traceback (most recent call last):
  File "C:\Program Files\OpenERP 7.0-20130918-231035\Server\server\openerp\addons\web\http.py", line 204, in dispatch
  File "C:\Program Files\OpenERP 7.0-20130918-231035\Server\server\openerp\addons\web\controllers\main.py", line 1132, in call_button
  File "C:\Program Files\OpenERP 7.0-20130918-231035\Server\server\openerp\addons\web\controllers\main.py", line 1120, in _call_kw
  File "C:\Program Files\OpenERP 7.0-20130918-231035\Server\server\openerp\addons\web\session.py", line 42, in proxy
  File "C:\Program Files\OpenERP 7.0-20130918-231035\Server\server\openerp\addons\web\session.py", line 30, in proxy_method
  File "C:\Program Files\OpenERP 7.0-20130918-231035\Server\server\openerp\addons\web\session.py", line 103, in send


Server Traceback (most recent call last):
  File "C:\Program Files\OpenERP 7.0-20130918-231035\Server\server\openerp\addons\web\session.py", line 89, in send
  File "C:\Program Files\OpenERP 7.0-20130918-231035\Server\server\.\openerp\netsvc.py", line 292, in dispatch_rpc
  File "C:\Program Files\OpenERP 7.0-20130918-231035\Server\server\.\openerp\service\web_services.py", line 626, in dispatch
  File "C:\Program Files\OpenERP 7.0-20130918-231035\Server\server\.\openerp\osv\osv.py", line 188, in execute_kw
  File "C:\Program Files\OpenERP 7.0-20130918-231035\Server\server\.\openerp\osv\osv.py", line 131, in wrapper
  File "C:\Program Files\OpenERP 7.0-20130918-231035\Server\server\.\openerp\osv\osv.py", line 197, in execute
  File "C:\Program Files\OpenERP 7.0-20130918-231035\Server\server\.\openerp\osv\osv.py", line 185, in execute_cr
  File "C:\Program Files\OpenERP 7.0-20130918-231035\Server\server\openerp\addons\base\module\module.py", line 513, in button_immediate_upgrade
  File "C:\Program Files\OpenERP 7.0-20130918-231035\Server\server\openerp\addons\base\module\module.py", line 475, in _button_immediate_function
  File "C:\Program Files\OpenERP 7.0-20130918-231035\Server\server\.\openerp\pooler.py", line 39, in restart_pool
  File "C:\Program Files\OpenERP 7.0-20130918-231035\Server\server\.\openerp\modules\registry.py", line 218, in new
  File "C:\Program Files\OpenERP 7.0-20130918-231035\Server\server\.\openerp\modules\loading.py", line 350, in load_modules
  File "C:\Program Files\OpenERP 7.0-20130918-231035\Server\server\.\openerp\modules\loading.py", line 256, in load_marked_modules
  File "C:\Program Files\OpenERP 7.0-20130918-231035\Server\server\.\openerp\modules\loading.py", line 188, in load_module_graph
  File "C:\Program Files\OpenERP 7.0-20130918-231035\Server\server\.\openerp\modules\loading.py", line 76, in <lambda>
  File "C:\Program Files\OpenERP 7.0-20130918-231035\Server\server\.\openerp\modules\loading.py", line 124, in _load_data
  File "C:\Program Files\OpenERP 7.0-20130918-231035\Server\server\.\openerp\tools\convert.py", line 954, in convert_xml_import
  File "C:\Program Files\OpenERP 7.0-20130918-231035\Server\server\.\openerp\tools\convert.py", line 847, in parse
  File "C:\Program Files\OpenERP 7.0-20130918-231035\Server\server\.\openerp\tools\convert.py", line 805, in _tag_record
  File "C:\Program Files\OpenERP 7.0-20130918-231035\Server\server\.\openerp\tools\convert.py", line 824, in id_get
  File "C:\Program Files\OpenERP 7.0-20130918-231035\Server\server\.\openerp\tools\convert.py", line 833, in model_id_get
  File "C:\Program Files\OpenERP 7.0-20130918-231035\Server\server\.\openerp\tools\cache.py", line 18, in lookup
  File "C:\Program Files\OpenERP 7.0-20130918-231035\Server\server\.\openerp\tools\cache.py", line 46, in lookup
  File "C:\Program Files\OpenERP 7.0-20130918-231035\Server\server\openerp\addons\base\ir\ir_model.py", line 869, in get_object_reference
  File "C:\Program Files\OpenERP 7.0-20130918-231035\Server\server\.\openerp\tools\cache.py", line 18, in lookup
  File "C:\Program Files\OpenERP 7.0-20130918-231035\Server\server\.\openerp\tools\cache.py", line 46, in lookup
  File "C:\Program Files\OpenERP 7.0-20130918-231035\Server\server\openerp\addons\base\ir\ir_model.py", line 862, in _get_id
ValueError: No such external ID currently defined in the system: vetclinic.base_view_partner_form

我的LOC是:

初始化的.py

 import vetclinic

OpenERP的的.py

    {
'name' : 'Vet Clinic',
'version' : '1.0' ,
'description' : """
    Vet Clinic application
    - List of Animals
    """ ,
    'author' : 'Ejaz' ,
    'website' : 'http://openerp.com',
    'depends' : ['base_setup'],
    'data' : ['vetclinic_view.xml'],
    'demo' :[],
    'installable' : True,
    'auto_install' : False,
    }

vetclinic.py

from openerp.osv import osv, fields
class vetclinic_animal(osv.Model):
    _name = "vetclinic.animal"
    _columns = {
        'name' : fields.char('Name', required= True, size=64),
        'birthdate' : fields.date('Birth Date'),
        'classification_id' : fields.many2one('vetclinic.classification', 'Classification'),
        'breed_id' : fields.many2one('vetclinic.breed', 'Breed'),
        'description' : fields.text('Description'),
        'labels_ids' : fields.many2many('vetclinic.labels', 'rel_animal_labels', 'animal_id', 'tags_id', string = "Labels"),
        'history' : fields.text("History"),
        'res_partner_id' : fields.many2one('res.partner', 'Owner'),


        }

class vetclinic_res_partner(osv.Model):
    _inherit= "res.partner"
    _name= "res.partner"
    _columns= {
        'animal_ids' : fields.one2many('vetclinic.animal', 'res_partner_id', string= "Pets"),
        }   
class vetclinic_classification(osv.Model):
    _name= "vetclinic.classification"

    _columns= {
        'name' : fields.char('Name', size= 32),
        }

class vetclinic_breed(osv.Model):
    _name= "vetclinic.breed"
    _columns= {
        'name' : fields.char('Name', size= 32),
        }

class vetclinic_labels(osv.Model):
    _name= "vetclinic.labels"
    _columns= {
        'name' : fields.char('Name', size= 64),
        }

vetclinic_view.py

 <?xml version= "1.0" encoding= "utf-8"?>
<openerp>
    <data>
        <record id= "vetclinic_animal_action" model = "ir.actions.act_window">
        <field name= "name">Animals</field>
        <field name= "res_model">vetclinic.animal</field>
        <field name= "view_type">form</field>
        <field name= "view_mode">tree,form</field>
        <field name= "help" type="html">
            <p class="oe_view_nocontent_create">Click Create to add a new animal record.</p>
        </field>
        </record>

        <record id= "vetclinic_classification_action" model = "ir.actions.act_window">
        <field name= "name">Classifications</field>
        <field name= "res_model">vetclinic.classification</field>
        <field name= "view_type">form</field>
        <field name= "view_mode">tree,form</field>
        <field name= "help" type="html">
            <p class="oe_view_nocontent_create">Click Create to add a new classification record.</p>
        </field>
        </record>

        <record id= "vetclinic_breed_action" model = "ir.actions.act_window">
        <field name= "name">Breeds</field>
        <field name= "res_model">vetclinic.breed</field>
        <field name= "view_type">form</field>
        <field name= "view_mode">tree,form</field>
        <field name= "help" type="html">
            <p class="oe_view_nocontent_create">Click Create to add a new breed record.</p>
        </field>
        </record>

        <record id= "base_view_partner_form" model = "ir.ui.view">
            <field name= "model">res.partner</field>
            <field name= "inherit_id" ref="base_view_partner_form"/>
            <field name= "arch" type="xml">
                <notebook position= "inside">
                    <page string= "Pets">
                    <field name="animal_ids" colspan="4" nolable="1"/>
                    </page>
                </notebook>
            </field>
        </record>

        <record id= "vetclinic_animal_form_view" model = "ir.ui.view">
        <field name= "name">vetclinic.animal.form.view</field>
        <field name= "view_type">form</field>
        <field name= "model">vetclinic.animal</field>
        <field name= "arch" type = "xml">
            <form string = "Animal">
                <field name = "name"/>
                <field name = "birthdate"/>
                <field name = "breed_id"/>
                <field name = "classification_id"/>
                <field name = "labels_ids" widget ="many2many_tags"/>
                <notebook colspan = "4">
                    <page string= "Animal Hitory">
                        <field name = "history" 
                            nolabel="1" 
                            placeholder= "Animal medical history goes here"/>
                            </page>
                </notebook>
                </form>
        </field>
        </record>

                <menuitem id= "vetclinic" name="Vet Clinic"/>
        <menuitem id= "vetclinic_menu" name= "Vet Clinic" parent="vetclinic" />
        <menuitem id= "vetclinic_animal_menu"
                    name = "Animals"
                    parent= "vetclinic_menu"
                    action = "vetclinic_animal_action"
            />
    <menuitem id= "vetclinic_classification_menu"
                    name = "Classifications"
                    parent= "vetclinic_menu"
                    action = "vetclinic_classification_action"
            />
    <menuitem id= "vetclinic_breed_menu"
                    name = "Breeds"
                    parent= "vetclinic_menu"
                    action = "vetclinic_breed_action"
            />
    </data>
</openerp>

1 个答案:

答案 0 :(得分:2)

这是因为您没有正确引用xml视图。在xml中它应该像

  <record id= "base_view_partner_form_inherited" model = "ir.ui.view">
        <field name= "model">res.partner</field>
        <field name= "inherit_id" ref="base.view_partner_form"/>
        <field name= "arch" type="xml">
            <notebook position= "inside">
                <page string= "Pets">
                <field name="animal_ids" colspan="4" nolable="1"/>
                </page>
            </notebook>
        </field>
    </record>

其中base是modelview_partner_form是该模型中的视图。你还应该改变记录的id。请记住,id应该在每个地方都是唯一的。