我是为Odoo开发模块的新手。我根据文档开始开发演示模块。但它给出了错误。我会为你提供所有文件和代码在这里。有人请帮忙......
我的 openerp .py文件
# -*- coding: utf-8 -*-
{
'name': "Daily Transaction Manager",
'summary': """
Used For Managing entrys of our daily transactions.""",
'description': """
Used For Managing entrys of our daily transactions
""",
'author': "Peniel Technology LLC",
'website': "http://www.penieltech.com.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': 'manager',
'version': '1.0',
# any module necessary for this one to work correctly
'depends': [],
# always loaded
'data': [
# 'security/ir.model.access.csv',
'daily_transaction_view.xml',
],
# only loaded in demonstration mode
'demo': [],
'installable': True,
'auto_install':False,
}
我的 init .py文件: -
import daily_transaction
我的daily_transaction.py文件
from openerp import fields,osv
class daily_transaction(osv.osv):
_name= "daily_transaction"
_description= "Daily Transaction"
_coloums = {
'subject': fields.char('Subject',size=128,required=True),
'date' : fields.date('Date',required=True),
'note' : fields.text('Notes'),
'amount' : fields.float('Amount',required=True),
'type' : fields.selection([
('transport','Transport'),
('household','Household'),
('personal','Personal'),
], 'Type',required=True),
}
我的daily_transaction_view.xml就像: -
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<!-- Action -->
<record id="action_daily_transaction" model="ir.actions.act_window">
<field name="name">Daily Transaction </field>
<field name="res_model">daily.transaction</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="search_view_id" eval="False"/>
<field name="context">{}</field>
<field name="help">Create new daily trasaction</field>
</record>
<!-- Menu Code here -->
<menuitem name="Daily Transaction" id="base.daily_transaction_roof" sequence="60"/>
<menuitem id="menu_daily_transaction_roof" name="Daily Transaction" parent="base.daily_transaction_roof" sequence="1"/>
<menuitem action="action_daily_transaction" id="menu_action_daily_transaction" parent="menu_daily_transaction_roof" sequence="20"/>
<!-- Tree-->
<record id="view_daily_transaction_tree" model="ir.ui.view">
<field name="name">daily.transaction.tree</field>
<field name="model">daily.transaction</field>
<field name="arch" type="xml">
<tree string="Daily Transaction">
<field name="name"/>
<field name="date"/>
<field name="type"/>
<field name="amount"/>
</tree>
</field>
</record>
<!--Form -->
<record id="view_daily_transaction_form" module="ir.ui.view">
<field name="name">daily.transaction.form.view</field>
<field name="model">daily.transaction</field>
<field name="arch" type="xml">
<form string="Daily Transaction" >
<group>
<field name="name"/>
<field name="date"/>
<field name="type"/>
<field name="amount"/>
<field name="note"/>
</group>
</form>
</field>
</record>
</data>
</openerp>
当我尝试安装时,我收到错误:
Odoo Server Error
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 643, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 680, in dispatch
result = self._call_function(**self.params)
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 316, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/service/model.py", line 118, in wrapper
return f(dbname, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 309, in checked_call
result = self.endpoint(*a, **kw)
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 959, in __call__
return self.method(*args, **kw)
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 509, in response_wrap
response = f(*args, **kw)
File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 896, in call_button
action = self._call_kw(model, method, args, {})
File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 884, in _call_kw
return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 250, in wrapper
return old_api(self, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/addons/base/module/module.py", line 459, 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 250, in wrapper
return old_api(self, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/addons/base/module/module.py", line 533, 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 386, 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 338, in load_modules
loaded_modules, update_module)
File "/usr/lib/python2.7/dist-packages/openerp/modules/loading.py", line 237, 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 156, 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 98, 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 851, 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 925, in convert_xml_import
relaxng.assert_(doc)
File "lxml.etree.pyx", line 3373, in lxml.etree._Validator.assert_ (src/lxml/lxml.etree.c:166352)
AssertionError: Element openerp has extra content: data, line 3
答案 0 :(得分:3)
I got the same error when using a wrong "value" attribute for field:
<field value="myvalue" name="myfield"/>
and I did fix it with:
<field name="myfield">myvalue</field>
Check that all your elements are properly closed.
It seems that the validation error message is not properly shown.
答案 1 :(得分:1)
.py文件和表单视图中存在拼写错误.....
_coloums --> _columns
.py file -->
_columns =
{ 'subject': fields.char('Subject',size=128,required=True),
'date' : fields.date('Date',required=True),
'note' : fields.text('Notes'),
'amount' : fields.float('Amount',required=True),
'type' : fields.selection([
('transport','Transport'),
('household','Household'),
('personal','Personal'),
], 'Type',required=True),
}
<!--Form -->
<record id="view_daily_transaction_form" **module**="ir.ui.view">
<record id="view_daily_transaction_form" **model**="ir.ui.view">
我希望这个答案对你有所帮助..谢谢
答案 2 :(得分:0)
在daily_transaction.py文件中,
int Staty_Postaci(int Final_Postac_Sila,
int Final_Postac_Inteligencja);
应该是,
void Tworzenie_postaci::Staty_Postaci(int& _Postac_Sila,
int& _Postac_Inteligencja)
{
...
}
答案 3 :(得分:0)
如果更改.xml文件中的任何代码,请保存该文件,然后必须重新启动服务器并升级模块,以便在服务器上再次加载已编辑的文件。
您可以通过命令行升级模块,如下所示:
range
只有在升级模块后才会进行更改。
答案 4 :(得分:0)
大多数情况下,问题是由某个地方的拼写错误引起的,例如XML标记中的属性名称或标记值在开始和结束标记之间,而不是在字段值之间。无论如何,请仔细检查,错误不会准确显示拼写错误的位置。
答案 5 :(得分:0)
在您的 daily_transaction_view.xml 第 3 行中有一个 <data>
元素。
Odoo 不希望在您的 XML 中出现这种情况。删除并尝试升级您的模块。它应该可以工作。
答案 6 :(得分:0)
您在 XML 文件中犯了拼写错误。
应该是model
而不是module
:
<record id="view_daily_transaction_form" model="ir.ui.view">
<field name="name">daily.transaction.form.view</field>
<field name="model">daily.transaction</field>
<field name="arch" type="xml">
<form string="Daily Transaction" >
<group>
<field name="name"/>
<field name="date"/>
<field name="type"/>
<field name="amount"/>
<field name="note"/>
</group>
</form>
</field>
</record>