我在我的poste windows 7上安装了Odoo v8。 我创建了一个新模块" openacademy" ,按照教程"构建模块"在官方网站上: https://www.odoo.com/documentation/8.0/howtos/backend.html
然后我压缩文件" openacademy" ==> " openacademy.zip"
问题:当我尝试导入模块时,出现此错误:
Import Module
WARNING odoo openerp.models: Cannot execute name_search, no _rec_name defined on base.import.module
INFO odoo werkzeug: 127.0.0.1 - - [16/Dec/2014 17:53:03] "POST /web/dataset/call_kw/base.import.module/search_read HTTP/1.1" 200 -
WARNING odoo openerp.modules.module: module openacademy: module not found
INFO odoo openerp.addons.base_import_module.models.ir_module: module openacademy: loading templates.xml
INFO odoo openerp.addons.base_import_module.models.ir_module: module openacademy: loading views/openacademy.xml
INFO odoo werkzeug: 127.0.0.1 - - [16/Dec/2014 17:53:07] "POST /longpolling/poll HTTP/1.1" 200 -
**ERROR odoo openerp.addons.base.ir.ir_ui_view: Model not found: openacademy.course**
Error context:
View 'course.form'
[view_id: 1030, xml_id: n/a, model: openacademy.course, parent_id: n/a]
模型" openacademy.course"找不到,但它已经存在于" models.py" !!!
这是我的代码:
models.py :
from openerp import models, fields
class Course(models.Model):
_name = 'openacademy.course'
name = fields.Char(string='Title', required=True)
description = fields.Text()
views / openacademy.xml :
<openerp>
<data>
<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>
<group>
<field name="name"/>
<field name="description"/>
</group>
</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>
</openerp>
__ init.py __ :
import models
答案 0 :(得分:2)
将models.py重命名为course.py
course.py:
from openerp import models, fields
class Course(models.Model):
_name = 'openacademy.course'
name = fields.Char(string='Title', required=True)
description = fields.Text()
将 __ init __。py 更改为:
import models
我认为模型文件的名称应该与类名匹配。您必须为每个表格制作不同的模型。
答案 1 :(得分:2)
来自goFrendiAsgard的一部分答案,试试这个:
运行&#34;更新应用列表&#34;在Odoo界面:
要查看此选项,您必须打开&#34;技术功能&#34;转到设置 - &gt;用户,编辑您的用户,然后单击&#34;技术功能&#34;。
重启Odoo服务器:
我不知道如何在Windows中执行此操作,在Linux中sudo service odoo-server restart
对于在Linux环境中遇到此问题的人,也可以尝试:
检查您的模块文件和文件夹是否拥有正确的所有者和组:
与其他模块比较,如有必要则进行更改。例如sudo chown -R odoo:odoo openacademy/
检查您的模块文件和文件夹权限:
通常为755,因此您可以运行sudo chmod -R 755 openacademy/