Skip to main content
 首页 » 编程设计

python之OpenERP/Odoo 意外 View 解析错误

2025年05月04日8yxwkf

大家好,

我正在从 OpenERP 6.1 更新到 Odoo8。 我有一个自己编写的模块,我调整了 Python 代码,一切看起来都很好,我也可以安装该模块,但是如果我加载一个 View ,我会收到以下错误:

  File "./openerp/models.py", line 1295, 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="//footer">' cannot be located in parent view 
 
Error context: 
    View `mail.compose.message.form` 
[view_id: 248, xml_id: email_template.email_compose_message_wizard_inherit_form, model:     mail.compose.message, parent_id: 216]" while parsing /home/gsatter/Dokumente    /odoo/odoo/seekda_addons/seekda_mail_extension/wizard/mail_compose_view.xml:4, near 
 
<record model="ir.ui.view" id="mail.email_compose_message_wizard_form"> 
        <field name="name">mail.compose.message.form</field> 
        <field name="model">mail.compose.message</field> 
        <field name="type">form</field> 
        <field name="arch" type="xml"> 
            <form string="Compose Email"> 
                <group col="6" colspan="4"> 
                    <field name="model" invisible="1"/> 
                    <field name="res_id" invisible="1"/> 
                    <field name="email_from" colspan="4" required="1"/> 
                    <field name="email_to" colspan="4" required="1"/> 
                    <field name="email_cc" colspan="4"/> 
                    <field name="email_bcc" colspan="4"/> 
                    <field name="reply_to" colspan="4"/> 
                    <field name="subject" colspan="4" widget="char" size="512"/> 
                    <field name="references" invisible="1"/> 
                    <field name="message_id" invisible="1"/> 
                </group> 
                <notebook colspan="4"> 
                    <page string="Body"> 
                        <field name="body_text" colspan="4" nolabel="1" height="300" width="300"/> 
                    </page> 
                    <page string="Attachments"> 
                        <field name="attachment_file_ids" colspan="4" nolabel="1" string="Files"> 
                            <form> 
                                <field name="data" filename="name" colspan="4"/> 
                                <field name="name" colspan="4"/> 
                            </form> 
                            <tree> 
                                <field name="data" filename="name" colspan="4"/> 
                                <field name="name" colspan="4"/> 
                            </tree> 
                        </field> 
                    </page> 
                </notebook> 
                <group col="4" colspan="4"> 
                    <label string="" name="placeholder" colspan="1"/> 
                    <button icon="gtk-close" special="cancel" string="Cancel"/> 
                    <button icon="gtk-ok" name="send_mail" string="Send" type="object"/> 
                </group> 
            </form> 
        </field> 
    </record> 

有人知道这个向导有什么问题吗? 这是我的观点(向导):

<?xml version="1.0" encoding="utf-8"?> 
<openerp> 
<data> 
    <record model="ir.ui.view" id="mail.email_compose_message_wizard_form"> 
        <field name="name">mail.compose.message.form</field> 
        <field name="model">mail.compose.message</field> 
        <field name="type">form</field> 
        <field name="arch" type="xml"> 
            <form string="Compose Email"> 
                <group col="6" colspan="4"> 
                    <field name="model" invisible="1"/> 
                    <field name="res_id" invisible="1"/> 
                    <field name="email_from" colspan="4" required="1"/> 
                    <field name="email_to" colspan="4" required="1"/> 
                    <field name="email_cc" colspan="4"/> 
                    <field name="email_bcc" colspan="4"/> 
                    <field name="reply_to" colspan="4"/> 
                    <field name="subject" colspan="4" widget="char" size="512"/> 
                    <field name="references" invisible="1"/> 
                    <field name="message_id" invisible="1"/> 
                </group> 
                <notebook colspan="4"> 
                    <page string="Body"> 
                        <field name="body_text" colspan="4" nolabel="1" height="300" width="300"/> 
                    </page> 
                    <page string="Attachments"> 
                        <field name="attachment_file_ids" colspan="4" nolabel="1" string="Files"> 
                            <form> 
                                <field name="data" filename="name" colspan="4"/> 
                                <field name="name" colspan="4"/> 
                            </form> 
                            <tree> 
                                <field name="data" filename="name" colspan="4"/> 
                                <field name="name" colspan="4"/> 
                            </tree> 
                        </field> 
                    </page> 
                </notebook> 
                <group col="4" colspan="4"> 
                    <label string="" name="placeholder" colspan="1"/> 
                    <button icon="gtk-close" special="cancel" string="Cancel"/> 
                    <button icon="gtk-ok" name="send_mail" string="Send" type="object"/> 
                </group> 
            </form> 
        </field> 
    </record> 
</data> 

她是一个继承 View 顶部的 View (它位于插件 email_template 中):

  <?xml version="1.0" encoding="utf-8"?> 
    <openerp> 
      <data> 
 
    <record model="ir.ui.view" id="email_compose_message_wizard_inherit_form"> 
        <field name="name">mail.compose.message.form</field> 
        <field name="model">mail.compose.message</field> 
        <field name="inherit_id" ref="mail.email_compose_message_wizard_form"/> 
        <field name="groups_id" eval="[(4,ref('base.group_user'))]"/> 
        <field name="arch" type="xml"> 
            <xpath expr="//footer" position="inside"> 
                <group class="oe_right oe_form" col="1"> 
                    <div>Use template 
                        <!--FIX: To avoid css issue of many2one field in footer temporary used oe_form (BUG:1152464)--> 
                        <field name="template_id" nolabel="1" class='oe_inline' 
                            options="{'no_create': True}" 
                            on_change="onchange_template_id(template_id, composition_mode, model, res_id, context)" domain="[('model_id.model','=',model)]" 
                            context="{'default_model': model, 'default_body_html': body, 'default_subject': subject}"/> 
                    </div> 
                    <button icon="/email_template/static/src/img/email_template_save.png" 
                        type="object" name="save_as_template" string="Save as new template" class="oe_link" 
                        help="Save as a new template"/> 
                </group> 
            </xpath> 
        </field> 
    </record> 
 
</data> 

谢谢

请您参考如下方法:

问题是

... 
... 
<field name="inherit_id" ref="mail.email_compose_message_wizard_form"/> 
... 
... 
    <xpath expr="//footer" position="inside"> 
    ... 
    ... 

您的上述 View 继承mail.email_compose_message_wizard_form看法。在您看来,您提到了 <xpath expr="//footer" position="inside">在父 View 的 footer 中添加以下代码标签。但是父 View 没有footer标签及其给出的错误 Element '<xpath expr="//footer">' cannot be located in parent view

你可以试试

<xpath expr="//notebook" position="inside">