【问题标题】:How can I solve this ParseError related to Odoo 9?如何解决与 Odoo 9 相关的 ParseError?
【发布时间】:2017-01-18 04:28:57
【问题描述】:

我是 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',
    ],
}

感谢您的帮助!

【问题讨论】:

  • 请将python代码添加到您的问题中。
  • 我做了@Kenly!感谢您的关注
  • 我在python代码中做到了!它被定义为模型的名称。
  • init.py 包含 : from .从导入控制器。导入模型
  • 它包含这一行: from .导入模型

标签: python xml odoo-9 parse-error


【解决方案1】:

我认为这是在抱怨您如何引用树、表单视图。但是,您尚未定义任何内容。在您拥有的代码上方定义树和表单视图。

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

【讨论】:

    猜你喜欢
    • 2016-05-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-04
    • 2021-10-22
    • 2016-05-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多