gpt4 book ai didi

python - 尝试在 Openerp 7.0 中安装自定义模块时出现 "Invalid XML for View Architecture"错误

转载 作者:行者123 更新时间:2023-12-01 04:36:15 28 4
gpt4 key购买 nike

当我尝试安装自定义模块时,出现如下错误:

ValidateError
Error occurred while validating the field(s) arch: Invalid XML for View Architecture!

这是我的模块:init.py

import daily_transaction

openerp.py

{
'name': 'Daily Transaction Manager',
'version': '1.0',
'category': 'manager',
'description': """
This module will manage daily transaction.
==========================================
""",
'author': 'Tarun',
'depends': [],
'data': ['daily_transaction_view.xml'],
'demo': [],
'installable': True,
'auto_install': False,

}

daily_transaction.py

from openerp.osv import fields, osv

class daily_transaction(osv.osv):
_name = "daily.transaction"
_description = "Daily Transaction"

_columns = {
'subject': fields.char('Subject',required=True,size=128),
'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()

daily_transaction_view.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Daily Transaction List View-->
<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>
<!-- Daily Transaction Form View-->
<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" version="7.0">
<group>
<field name="name"/>
<field name="date"/>
<field name="type"/>
<field name="amount"/>
<field name="note"/>
</group>
</form>
</field>
</record>
<record id="action_daily_transaction" model="ir.actions.act_window">
<field name="name">Daily Transaction</field>
<field name="type">ir.actions.act_window</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 transaction here.</field>
</record>
<!-- Main Menu -->
<menuitem name="Daily Transaction" id="base.daily_transaction_root" sequence="60"/>
<!-- Sub Menu -->
<menuitem id="menu_daily_transaction_root" name="Daily Transaction" parent="base.daily_transaction_root" sequence="1"/>
<!-- Action -->
<menuitem action="action_daily_transaction" id="menu_action_daily_transaction" parent="menu_daily_transaction_root" sequence="20"/>
</data>
</openerp>

这是日志错误:

2015-07-27 01:30:51,405 976 INFO odoo openerp.modules.module: module daily_transaction: creating or updating database tables 2015-07-27 01:30:51,431 976 INFO odoo openerp.modules.loading: module daily_transaction: loading daily_transaction_view.xml 2015-07-27 01:30:51,446 976 ERROR odoo openerp.osv.orm: Can't find field 'name' in the following view parts composing the view of object model 'daily.transaction': * daily.transaction.tree

Either you wrongly customized this view, or some modules bringing those views are not compatible with your current data model 2015-07-27 01:30:51,447 976 ERROR odoo openerp.addons.base.ir.ir_ui_view: Can't render view for model: daily.transaction Traceback (most recent call last): File "C:\OpenERP 7.0-20131109-002558\Server\server\openerp\addons\base\ir\ir_ui_view.py", line 126, in _check_render_view File "C:\OpenERP 7.0-20131109-002558\Server\server.\openerp\osv\orm.py", line 2264, in fields_view_get File "C:\OpenERP 7.0-20131109-002558\Server\server.\openerp\osv\orm.py", line 1941, in __view_look_dom_arch except_orm: ('View error', u"Can't find field 'name' in the following view parts composing the view of object model 'daily.transaction':\n * daily.transaction.tree\n\nEither you wrongly customized this view, or some modules bringing those views are not compatible with your current data model") 2015-07-27 01:30:51,461 976 ERROR odoo openerp.tools.convert: Parse error in file:///C:/OpenERP%207.0-20131109-002558/Server/server/openerp/addons/daily_transaction/daily_transaction_view.xml:5:

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

回溯-

Traceback (most recent call last):
File "C:\OpenERP 7.0-20131109-002558\Server\server\.\openerp\tools\convert.py", line 847, in parse
File "C:\OpenERP 7.0-20131109-002558\Server\server\.\openerp\tools\convert.py", line 814, in _tag_record
File "C:\OpenERP 7.0-20131109-002558\Server\server\openerp\addons\base\ir\ir_model.py", line 967, in _update
File "C:\OpenERP 7.0-20131109-002558\Server\server\openerp\addons\base\ir\ir_ui_view.py", line 103, in create
File "C:\OpenERP 7.0-20131109-002558\Server\server\.\openerp\osv\orm.py", line 4478, in create
File "C:\OpenERP 7.0-20131109-002558\Server\server\.\openerp\osv\orm.py", line 1548, in _validate
except_orm: ('ValidateError', u'Error occurred while validating the field(s) arch: Invalid XML for View Architecture!')
2015-07-27 01:30:51,463 976 ERROR odoo openerp.netsvc: ValidateError
Error occurred while validating the field(s) arch: Invalid XML for View Architecture!
Traceback (most recent call last):
File "C:\OpenERP 7.0-20131109-002558\Server\server\.\openerp\netsvc.py", line 292, in dispatch_rpc
File "C:\OpenERP 7.0-20131109-002558\Server\server\.\openerp\service\web_services.py", line 626, in dispatch

上面的模块来自http://www.slideshare.net/TarunBehal1/odoo-open-erp-creating-a-module-37569034?related=1

我已经尝试了其他帖子中的几种方法(使用 xpath、在新数据库上安装模块、更新基本模块等),但仍然出现相同的错误。

我的代码哪里做错了?

最佳答案

它们在 daily_transaction.py 中没有“名称”字段,您可以添加名称字段或将 daily_transaction_view.xml 更改为其他定义的列

<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" version="7.0">
<group>
<!-- <field name="name"/> --> <!--this was the error line -->
<field name="subject"/>
<field name="date"/>
<field name="type"/>
<field name="amount"/>
<field name="note"/>
</group>
</form>
</field>
</record>

关于python - 尝试在 Openerp 7.0 中安装自定义模块时出现 "Invalid XML for View Architecture"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31644013/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com