odoo 8 ParseError:“ValidateError Field(s)`arch`对约束失败:视图定义无效

时间:2015-09-30 08:38:23

标签: xml python-2.7 openerp

我正在尝试在Odoo 8中安装模块,并收到以下错误:

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 537, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 574, in dispatch
    result = self._call_function(**self.params)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 310, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/service/model.py", line 113, in wrapper
    return f(dbname, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 307, in checked_call
    return self.endpoint(*a, **kw)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 803, in __call__
    return self.method(*args, **kw)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 403, in response_wrap
    response = f(*args, **kw)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 952, in call_button
    action = self._call_kw(model, method, args, {})
  File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 940, in _call_kw
    return checked_call(request.db, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/service/model.py", line 113, in wrapper
    return f(dbname, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 939, in checked_call
    return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/base/module/module.py", line 447, in button_immediate_install
    return self._button_immediate_function(cr, uid, ids, self.button_install, context=context)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/base/module/module.py", line 495, in _button_immediate_function
    registry = openerp.modules.registry.RegistryManager.new(cr.dbname, update_module=True)
  File "/usr/lib/python2.7/dist-packages/openerp/modules/registry.py", line 370, in new
    openerp.modules.load_modules(registry._db, force_demo, status, update_module)
  File "/usr/lib/python2.7/dist-packages/openerp/modules/loading.py", line 355, in load_modules
    loaded_modules, update_module)
  File "/usr/lib/python2.7/dist-packages/openerp/modules/loading.py", line 255, in load_marked_modules
    loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
  File "/usr/lib/python2.7/dist-packages/openerp/modules/loading.py", line 176, in load_module_graph
    _load_data(cr, module_name, idref, mode, kind='data')
  File "/usr/lib/python2.7/dist-packages/openerp/modules/loading.py", line 118, in _load_data
    tools.convert_file(cr, module_name, filename, idref, mode, noupdate, kind, report)
  File "/usr/lib/python2.7/dist-packages/openerp/tools/convert.py", line 901, in convert_file
    convert_xml_import(cr, module, fp, idref, mode, noupdate, report)
  File "/usr/lib/python2.7/dist-packages/openerp/tools/convert.py", line 987, in convert_xml_import
    obj.parse(doc.getroot(), mode=mode)
  File "/usr/lib/python2.7/dist-packages/openerp/tools/convert.py", line 853, in parse
    self._tags[rec.tag](self.cr, rec, n, mode=mode)
  File "/usr/lib/python2.7/dist-packages/openerp/tools/convert.py", line 763, in _tag_record
    id = self.pool['ir.model.data']._update(cr, self.uid, rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode, context=rec_context )
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/base/ir/ir_model.py", line 1077, in _update
    res_id = model_obj.create(cr, uid, values, context=context)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/base/ir/ir_ui_view.py", line 255, in create
    context=context)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 336, in old_api
    result = method(recs, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 4084, in create
    record = self.browse(self._create(old_vals))
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 239, in wrapper
    return new_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 472, in new_api
    result = method(self._model, cr, uid, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 4275, in _create
    recs._validate_fields(vals)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 239, in wrapper
    return new_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 1272, in _validate_fields
    raise ValidationError('\n'.join(errors))
ParseError: "ValidateError
Field(s) `arch` failed against a constraint: Invalid view definition

Error details:
Element '<xpath expr="/form/sheet/notebook/page[@string='General Properties']">' cannot be located in parent view

Error context:
View `Inherited Fleet Vehicle Form`
[view_id: 779, xml_id: n/a, model: fleet.vehicle, parent_id: 685]" while parsing /usr/lib/python2.7/dist-packages/openerp/addons/transport_sale-master/transport_sale.xml:125, near
<record model="ir.ui.view" id="inherited_fleet_vehicle_form_view">
            <field name="name">Inherited Fleet Vehicle Form</field>
            <field name="model">fleet.vehicle</field>
            <field name="inherit_id" ref="fleet.fleet_vehicle_form"/>
            <field name="arch" type="xml">
                <data><xpath expr="//label[@for='tag_ids']" position="before">
                      <label for="internal_number" class="oe_edit_only"/>                      
                    <h2>
                        <field name="internal_number" class="oe_inline"/>                                               
                    </h2>
                     <label for="is_trailer" class="oe_edit_only"/>                 
                     <field name="is_trailer" string="Is Trailer" help="Mark this if the vehicle is a trailer"/>
                </xpath>
                <xpath expr="/form/sheet/notebook/page[@string='General Properties']" position="after">
                    <page string="Transport sales">
                        <field name="sales_order_ids" readonly="1">
                            <tree editable="bottom">
                                <field name="sale_order_id"/>
                                <field name="sales_date"/>
                                <field name="partner_departure_id"/>
                                <field name="partner_destination_id"/>
                                <field name="delivery_date"/>
                                <field name="return_date"/>
                            </tree>
                        </field>
                    </page>
                </xpath>
            </data></field>
        </record>

根据错误,模块的违规部分似乎是:

 <!-- Fleet vehicle sales form -->
<record model="ir.ui.view" id="inherited_fleet_vehicle_form_view">
  <field name="name">Inherited Fleet Vehicle Form</field>
  <field name="model">fleet.vehicle</field>
  <field name="inherit_id" ref="fleet.fleet_vehicle_form" />
  <field name="arch" type="xml">
    <xpath expr="//label[@for='tag_ids']" position="before">
      <label for="internal_number" class="oe_edit_only"/>
      <h2>
        <field name="internal_number" class="oe_inline" />
      </h2>
      <label for="is_trailer" class="oe_edit_only"/>
      <field name="is_trailer" string="Is Trailer" help="Mark this if the vehicle is a trailer"/>
    </xpath>
    <xpath expr="/form/sheet/notebook/page[@string='General Properties']" position="after">
      <page string="Transport sales">
        <field name="sales_order_ids" readonly="1">
          <tree editable="bottom">
            <field name="sale_order_id" />
            <field name="sales_date" />
            <field name="partner_departure_id" />
            <field name="partner_destination_id" />
            <field name="delivery_date" />
            <field name="return_date" />
          </tree>
        </field>
      </page>
    </xpath>
  </field>
</record>

发现有大量类似错误的帖子,各种解决方案似乎都有所不同,但似乎没有一个对我有用。我该怎么办?

修改

清理第一个代码块并在第二个代码块中替换为完整错误 申请后

<xpath expr="/form/sheet/group[@string='General Properties']" position="after">

如下面的评论所示,我的错误如下:

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 537, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 574, in dispatch
    result = self._call_function(**self.params)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 310, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/service/model.py", line 113, in wrapper
    return f(dbname, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 307, in checked_call
    return self.endpoint(*a, **kw)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 803, in __call__
    return self.method(*args, **kw)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 403, in response_wrap
    response = f(*args, **kw)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 952, in call_button
    action = self._call_kw(model, method, args, {})
  File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 940, in _call_kw
    return checked_call(request.db, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/service/model.py", line 113, in wrapper
    return f(dbname, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 939, in checked_call
    return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/base/module/module.py", line 447, in button_immediate_install
    return self._button_immediate_function(cr, uid, ids, self.button_install, context=context)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/base/module/module.py", line 495, in _button_immediate_function
    registry = openerp.modules.registry.RegistryManager.new(cr.dbname, update_module=True)
  File "/usr/lib/python2.7/dist-packages/openerp/modules/registry.py", line 370, in new
    openerp.modules.load_modules(registry._db, force_demo, status, update_module)
  File "/usr/lib/python2.7/dist-packages/openerp/modules/loading.py", line 355, in load_modules
    loaded_modules, update_module)
  File "/usr/lib/python2.7/dist-packages/openerp/modules/loading.py", line 255, in load_marked_modules
    loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
  File "/usr/lib/python2.7/dist-packages/openerp/modules/loading.py", line 176, in load_module_graph
    _load_data(cr, module_name, idref, mode, kind='data')
  File "/usr/lib/python2.7/dist-packages/openerp/modules/loading.py", line 118, in _load_data
    tools.convert_file(cr, module_name, filename, idref, mode, noupdate, kind, report)
  File "/usr/lib/python2.7/dist-packages/openerp/tools/convert.py", line 901, in convert_file
    convert_xml_import(cr, module, fp, idref, mode, noupdate, report)
  File "/usr/lib/python2.7/dist-packages/openerp/tools/convert.py", line 987, in convert_xml_import
    obj.parse(doc.getroot(), mode=mode)
  File "/usr/lib/python2.7/dist-packages/openerp/tools/convert.py", line 853, in parse
    self._tags[rec.tag](self.cr, rec, n, mode=mode)
  File "/usr/lib/python2.7/dist-packages/openerp/tools/convert.py", line 763, in _tag_record
    id = self.pool['ir.model.data']._update(cr, self.uid, rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode, context=rec_context )
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/base/ir/ir_model.py", line 1077, in _update
    res_id = model_obj.create(cr, uid, values, context=context)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/base/ir/ir_ui_view.py", line 255, in create
    context=context)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 336, in old_api
    result = method(recs, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 4084, in create
    record = self.browse(self._create(old_vals))
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 239, in wrapper
    return new_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 472, in new_api
    result = method(self._model, cr, uid, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 4275, in _create
    recs._validate_fields(vals)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 239, in wrapper
    return new_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 1272, in _validate_fields
    raise ValidationError('\n'.join(errors))
ParseError: "ValidateError
Field(s) `arch` failed against a constraint: Invalid view definition" while parsing /usr/lib/python2.7/dist-packages/openerp/addons/transport_sale-master/transport_sale.xml:125, near
<record model="ir.ui.view" id="inherited_fleet_vehicle_form_view">
            <field name="name">Inherited Fleet Vehicle Form</field>
            <field name="model">fleet.vehicle</field>
            <field name="inherit_id" ref="fleet.fleet_vehicle_form"/>
            <field name="arch" type="xml">
                <data><xpath expr="//label[@for='tag_ids']" position="before">
                      <label for="internal_number" class="oe_edit_only"/>                      
                    <h2>
                        <field name="internal_number" class="oe_inline"/>       
                    </h2>
                     <label for="is_trailer" class="oe_edit_only"/>                 
                     <field name="is_trailer" string="Is Trailer" help="Mark this if the vehicle is a trailer"/>
                </xpath>
                <xpath expr="/form/sheet/group[@string='General Properties']" position="after">
                    <page string="Transport sales">
                        <field name="sales_order_ids" readonly="1">
                            <tree editable="bottom">
                                <field name="sale_order_id"/>
                                <field name="sales_date"/>
                                <field name="partner_departure_id"/>
                                <field name="partner_destination_id"/>
                                <field name="delivery_date"/>
                                <field name="return_date"/>
                            </tree>
                        </field>
                    </page>
                </xpath>
            </data></field>
        </record>

修改

根据建议替换[@name]的[@string]之后,错误仍然如下所示。

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 537, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 574, in dispatch
    result = self._call_function(**self.params)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 310, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/service/model.py", line 113, in wrapper
    return f(dbname, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 307, in checked_call
    return self.endpoint(*a, **kw)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 803, in __call__
    return self.method(*args, **kw)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 403, in response_wrap
    response = f(*args, **kw)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 952, in call_button
    action = self._call_kw(model, method, args, {})
  File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 940, in _call_kw
    return checked_call(request.db, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/service/model.py", line 113, in wrapper
    return f(dbname, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 939, in checked_call
    return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/base/module/module.py", line 447, in button_immediate_install
    return self._button_immediate_function(cr, uid, ids, self.button_install, context=context)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/base/module/module.py", line 495, in _button_immediate_function
    registry = openerp.modules.registry.RegistryManager.new(cr.dbname, update_module=True)
  File "/usr/lib/python2.7/dist-packages/openerp/modules/registry.py", line 370, in new
    openerp.modules.load_modules(registry._db, force_demo, status, update_module)
  File "/usr/lib/python2.7/dist-packages/openerp/modules/loading.py", line 355, in load_modules
    loaded_modules, update_module)
  File "/usr/lib/python2.7/dist-packages/openerp/modules/loading.py", line 255, in load_marked_modules
    loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
  File "/usr/lib/python2.7/dist-packages/openerp/modules/loading.py", line 176, in load_module_graph
    _load_data(cr, module_name, idref, mode, kind='data')
  File "/usr/lib/python2.7/dist-packages/openerp/modules/loading.py", line 118, in _load_data
    tools.convert_file(cr, module_name, filename, idref, mode, noupdate, kind, report)
  File "/usr/lib/python2.7/dist-packages/openerp/tools/convert.py", line 901, in convert_file
    convert_xml_import(cr, module, fp, idref, mode, noupdate, report)
  File "/usr/lib/python2.7/dist-packages/openerp/tools/convert.py", line 987, in convert_xml_import
    obj.parse(doc.getroot(), mode=mode)
  File "/usr/lib/python2.7/dist-packages/openerp/tools/convert.py", line 853, in parse
    self._tags[rec.tag](self.cr, rec, n, mode=mode)
  File "/usr/lib/python2.7/dist-packages/openerp/tools/convert.py", line 763, in _tag_record
    id = self.pool['ir.model.data']._update(cr, self.uid, rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode, context=rec_context )
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/base/ir/ir_model.py", line 1077, in _update
    res_id = model_obj.create(cr, uid, values, context=context)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/base/ir/ir_ui_view.py", line 255, in create
    context=context)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 336, in old_api
    result = method(recs, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 4084, in create
    record = self.browse(self._create(old_vals))
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 239, in wrapper
    return new_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 472, in new_api
    result = method(self._model, cr, uid, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 4275, in _create
    recs._validate_fields(vals)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 239, in wrapper
    return new_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 1272, in _validate_fields
    raise ValidationError('\n'.join(errors))
ParseError: "ValidateError
Field(s) `arch` failed against a constraint: Invalid view definition

Error details:
Element '<xpath expr="/form/sheet/notebook/page[@name='General Properties']">' cannot be located in parent view

Error context:
View `Inherited Fleet Vehicle Form`
[view_id: 866, xml_id: n/a, model: fleet.vehicle, parent_id: 830]" while parsing /usr/lib/python2.7/dist-packages/openerp/addons/transport_sale-master/transport_sale.xml:125, near
<record model="ir.ui.view" id="inherited_fleet_vehicle_form_view">
            <field name="name">Inherited Fleet Vehicle Form</field>
            <field name="model">fleet.vehicle</field>
            <field name="inherit_id" ref="fleet.fleet_vehicle_form"/>
            <field name="arch" type="xml">
                <data><xpath expr="//label[@for='tag_ids']" position="before">
                      <label for="internal_number" class="oe_edit_only"/>                      
                    <h2>
                        <field name="internal_number" class="oe_inline"/>                                               
                    </h2>
                     <label for="is_trailer" class="oe_edit_only"/>                 
                     <field name="is_trailer" string="Is Trailer" help="Mark this if the vehicle is a trailer"/>
                </xpath>
                <xpath expr="/form/sheet/notebook/page[@name='General Properties']" position="after">
                    <page string="Transport sales">
                        <field name="sales_order_ids" readonly="1">
                            <tree editable="bottom">
                                <field name="sale_order_id"/>
                                <field name="sales_date"/>
                                <field name="partner_departure_id"/>
                                <field name="partner_destination_id"/>
                                <field name="delivery_date"/>
                                <field name="return_date"/>
                            </tree>
                        </field>
                    </page>
                </xpath>
            </data></field>
        </record>

这里空间不足;)编辑发布在

下面

3 个答案:

答案 0 :(得分:1)

错误显示在父视图(fleet_vehicle_form)中找不到您定义的路径。

您需要更正该xpath。

使用Odoo- v8.0时,

<xpath expr="/form/sheet/notebook/page[@string='General Properties']" position="after">

使用以下内容更改此xpath ...

<xpath expr="/form/sheet/group[@string='General Properties']" position="after">

父视图中没有notebook & page个标记(fleet_vehicle_form)。所以,这就是为什么它会给你错误。

答案 1 :(得分:0)

查看继承

Odoo不是修改现有视图(通过覆盖它们),而是提供视图继承,其中子视图“扩展”视图应用于根视图之上,并且可以添加或删除其父视图中的内容。

扩展视图使用inherit_id字段引用其父级。

提示

匹配单个元素时,可以直接在要查找的元素上设置position属性。下面的两个遗产都会给出相同的结果。

<xpath expr="//field[@name='field_name']" position="after">
    <field name="new_field" />
</xpath>

<field name="field_name" position="after">
    <field name="new_field" />
</field>

页面无法在组后添加,您需要将其放在侧页或任何其他页面之后/之前。

<xpath expr="/form/sheet/group[@string='General Properties']" position="after">

将此行更新为

<page string="existing page string" position="after">
    <!-- add your page here -->
</page>

视图继承中非常重要的是 PRIORITY ,但似乎大多数都被忽略了。

<field name="priority" eval="50" />

优先级定义在可以使用父子层次结构的情况下执行创建视图的时间。

<record model="ir.ui.view" id="inherited_fleet_vehicle_form_view">
    <field name="name">Inherited Fleet Vehicle Form</field>
    <field name="model">fleet.vehicle</field>
    <field name="inherit_id" ref="fleet.fleet_vehicle_form"/>
    <field name="priority" eval="50" />
    <field name="arch" type="xml">
        <xpath expr="//label[@for='tag_ids']" position="before">
              <label for="internal_number" class="oe_edit_only"/>                      
            <h2>
                <field name="internal_number" class="oe_inline"/>       
            </h2>
             <label for="is_trailer" class="oe_edit_only"/>                 
             <field name="is_trailer" string="Is Trailer" help="Mark this if the vehicle is a trailer"/>
        </xpath>
        <sheet position="inside">
            <page string="Transport sales">
                <field name="sales_order_ids" readonly="1">
                    <tree editable="bottom">
                        <field name="sale_order_id"/>
                        <field name="sales_date"/>
                        <field name="partner_departure_id"/>
                        <field name="partner_destination_id"/>
                        <field name="delivery_date"/>
                        <field name="return_date"/>
                    </tree>
                </field>
            </page>
        </sheet>
    </field>
</record>

答案 2 :(得分:0)

我得到了相同的错误“字段arch对约束失败:视图定义无效”,我使用了另一个模块中的字段,需要在中的'depends'中列出openerp .py文件。希望这有帮助。