如何解决与Odoo 9相关的ParseError?

时间:2016-09-10 00:45:08

标签: python xml odoo-9 parse-error

我是odoo的新手,我正在尝试使用odoo 9的文档构建模块。

我已经创建了模块并且已经安装了它,但是当我想添加xml文件时,会发生错误,特别是当我添加行' views / openacademy.xml'到 openerp .py:

ParseError : "Modèle non valide dans la définition de l'action"

None" while parsing file:///D:/Odoo/Odoo%209/server/openep/addons/openacademy/views/openacademy.xml:9, near

       <record model="ir.actions.act_window" id="course_list_action">
            <field name="name">Courses</field>
            <field name="res_model">openacademy.course</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">Create the first course
                </p>
            </field>
        </record>

我的代码:

openacademy.py:

from openerp import models, fields, api

class Course(models.Model):
    _name = 'openacademy.course'

    name = fields.Char(string="Title", required=True)
    description = fields.Text()

openacademy.xml:

<?xml version="1.0" encoding="UTF-8"?>
<openerp>
    <data>
        <!-- window action -->
        <!--
            The following tag is an action definition for a "window action",
            that is an action opening a view or a set of views
        -->
        <record model="ir.actions.act_window" id="course_list_action">
            <field name="name">Courses</field>
            <field name="res_model">openacademy.course</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">Create the first course
                </p>
            </field>
        </record>

        <!-- top level menu: no parent -->
        <menuitem id="main_openacademy_menu" name="Open Academy"/>
        <!-- A first level in the left side menu is needed
             before using action= attribute -->
        <menuitem id="openacademy_menu" name="Open Academy"
                  parent="main_openacademy_menu"/>
        <!-- the following menuitem should appear *after*
             its parent openacademy_menu and *after* its
             action course_list_action -->
        <menuitem id="courses_menu" name="Courses" parent="openacademy_menu"
                  action="course_list_action"/>
        <!-- Full id location:
             action="openacademy.course_list_action"
             It is not required when it is the same module -->
    </data>
</openerp>

__ openerp__.py:

# -*- coding: utf-8 -*-
{
    'name': "OpenAcademy",

    'summary': """
        My module is the first step to the manipulation of odoo""",

    'description': """
        Description is not necessary for the moment
    """,

    'author': "Osskadd",
    'website': "http://www.Thinkey.com",

    # Categories can be used to filter modules in modules listing
    # Check https://github.com/odoo/odoo/blob/master/openerp/addons/base/module/module_data.xml
    # for the full list
    'category': 'Ecommerce',
    'version': '0.1',

    # any module necessary for this one to work correctly
    'depends': ['base'],

    # always loaded
    'data': [
        # 'security/ir.model.access.csv',
        'views/openacademy.xml',
        'views/templates.xml',


    ],
    # only loaded in demonstration mode
    'demo': [
        'demo/demo.xml',
    ],
}

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

我认为它抱怨你如何引用树,表单视图。但是你没有定义任何。在您拥有的代码上方定义树和表单视图。

<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>

    <record model="ir.ui.view" id="course_tree_view">
        <field name="name">course.tree</field>
        <field name="model">openacademy.course</field>
        <field name="arch" type="xml">
            <tree string="Courses Tree">
                <!-- YOUR TREE VIEW HERE -->
            </tree>
        </field>
    </record>

    <record model="ir.ui.view" id="course_form_view">
        <field name="name">course.form</field>
        <field name="model">openacademy.course</field>
        <field name="arch" type="xml">
            <form string="Course Form">
                <sheet>
                <!-- YOUR FORM VIEW HERE -->
                </sheet>
            </form>
        </field>
    </record>  


    <!-- window action -->
    <!--
        The following tag is an action definition for a "window action",
        that is an action opening a view or a set of views
    -->
    <record model="ir.actions.act_window" id="course_list_action">
        <field name="name">Courses</field>
        <field name="res_model">openacademy.course</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">Create the first course
            </p>
        </field>
    </record>

    <!-- top level menu: no parent -->
    <menuitem id="main_openacademy_menu" name="Open Academy"/>
    <!-- A first level in the left side menu is needed
         before using action= attribute -->
    <menuitem id="openacademy_menu" name="Open Academy"
              parent="main_openacademy_menu"/>
    <!-- the following menuitem should appear *after*
         its parent openacademy_menu and *after* its
         action course_list_action -->
    <menuitem id="courses_menu" name="Courses" parent="openacademy_menu"
              action="course_list_action"/>
    <!-- Full id location:
         action="openacademy.course_list_action"
         It is not required when it is the same module -->
</data>