1

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

我的初始化.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
4

7 回答 7

3

为字段使用错误的“值”属性时,我遇到了同样的错误:

<field value="myvalue" name="myfield"/>

我确实修复了它:

<field name="myfield">myvalue</field>

检查所有元素是否正确关闭。

似乎没有正确显示验证错误消息。

于 2016-04-15T15:13:08.637 回答
2

.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"> 

我希望这个答案对你有帮助..谢谢

于 2016-03-18T06:46:42.917 回答
0

在您的 daily_transaction_view.xml 第 3 行中有一个<data>元素。

Odoo 并不期望在您的 XML 中出现这种情况。删除并尝试升级您的模块。它应该工作。

于 2021-02-23T08:36:54.257 回答
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>
于 2021-02-23T09:34:35.720 回答
0

大多数情况下,问题是由某个地方的拼写错误引起的,例如 XML 标记中的属性名称或标记值位于开始和结束标记之间,但不是字段值。无论如何,请仔细检查,错误不会准确显示拼写错误的位置。

于 2018-12-14T06:40:11.043 回答
0

如果您更改 .xml 文件中的任何代码,请保存该文件,您必须重新启动服务器并升级您的模块,以便您编辑的文件再次加载到服务器上。

您可以通过命令行升级您的模块,如下所示:

./odoo.py -d db_name -u module_name

只有在升级您的模块后,更改才会发生。

于 2016-02-26T13:19:09.083 回答
0

在 daily_transaction.py 文件中,

_name= "daily_transaction"

它应该像,

_name= "daily.transaction"
于 2016-02-26T03:10:36.847 回答