2014-02-08 57 views
1

我正在學習如何在OpenERP v7上開發模塊。 Everthing OK,直到我試圖添加一個嚮導:OpenERP不會接受我的視圖架構,我無法弄清楚爲什麼!OpenErp嚮導 - 視圖體系結構的無效XML

模塊架構爲:

  • _ init.py _(其中I導入module.py和嚮導)
  • _ openerp.py _(依賴關係:鹼; data:view/view.xml; wizard/wizard.xml)
  • module.py(其中我有主代碼,一切正常)
  • 視圖/ view.xml用(與主代碼去主視圖中,沒問題)
  • 嚮導/ _ init.py _(導入嚮導)
  • 嚮導/ wizard.py (下面的代碼)(下面的代碼)
  • 嚮導/ wizard.xml

這裏是wizard.py文件:

# -*- coding: utf-8 -*- 
from openerp.osv import fields, osv 

class idea_wizard(osv.TransientModel): 
    _name = 'idea.wizard' 
    _columns = { 
       'idea_age': fields.integer('Age'), 
       } 

這裏是wizard.xml文件:

<?xml version="1.0"?> 
<openerp> 
    <data> 
     <!-- Idea Category Form View --> 
     <record model="ir.ui.view" id="view_idea_wizard_form"> 
      <field name="name">idea.wizard.form</field> 
      <field name="model">idea.wizard</field> 
      <field name="arch" type="xml"> 
       <form string="Cleanup" version="7.0"> 
        <field name="idea_age"/> 
       </form> 
      </field> 
     </record> 
    </data> 
</openerp> 

這是所有基本的時刻,但我想有它的工作,所以我可以建立在它...

這裏是服務器追蹤:

Server Traceback (most recent call last): 
    File "/usr/lib/pymodules/python2.7/openerp/addons/web/session.py", line 89, in send 
return openerp.netsvc.dispatch_rpc(service_name, method, args) 
    File "/usr/lib/pymodules/python2.7/openerp/netsvc.py", line 292, in dispatch_rpc 
result = ExportService.getService(service_name).dispatch(method, params) 
    File "/usr/lib/pymodules/python2.7/openerp/service/web_services.py", line 622, in dispatch 
security.check(db,uid,passwd) 
    File "/usr/lib/pymodules/python2.7/openerp/service/security.py", line 40, in check 
pool = pooler.get_pool(db) 
    File "/usr/lib/pymodules/python2.7/openerp/pooler.py", line 49, in get_pool 
return get_db_and_pool(db_name, force_demo, status, update_module)[1] 
    File "/usr/lib/pymodules/python2.7/openerp/pooler.py", line 33, in get_db_and_pool 
registry = RegistryManager.get(db_name, force_demo, status, update_module) 
    File "/usr/lib/pymodules/python2.7/openerp/modules/registry.py", line 203, in get 
update_module) 
    File "/usr/lib/pymodules/python2.7/openerp/modules/registry.py", line 233, in new 
openerp.modules.load_modules(registry.db, force_demo, status, update_module) 
    File "/usr/lib/pymodules/python2.7/openerp/modules/loading.py", line 350, in load_modules 
force, status, report, loaded_modules, update_module) 
    File "/usr/lib/pymodules/python2.7/openerp/modules/loading.py", line 256, 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/pymodules/python2.7/openerp/modules/loading.py", line 188, in load_module_graph 
load_data(module_name, idref, mode) 
    File "/usr/lib/pymodules/python2.7/openerp/modules/loading.py", line 76, in <lambda> 
load_data = lambda *args: _load_data(cr, *args, kind='data') 
    File "/usr/lib/pymodules/python2.7/openerp/modules/loading.py", line 124, in _load_data 
tools.convert_xml_import(cr, module_name, fp, idref, mode, noupdate, report) 
    File "/usr/lib/pymodules/python2.7/openerp/tools/convert.py", line 954, in convert_xml_import 
obj.parse(doc.getroot()) 
    File "/usr/lib/pymodules/python2.7/openerp/tools/convert.py", line 847, in parse 
self._tags[rec.tag](self.cr, rec, n) 
    File "/usr/lib/pymodules/python2.7/openerp/tools/convert.py", line 814, in _tag_record 
id = self.pool.get('ir.model.data')._update(cr, self.uid, rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode, context=rec_context) 
    File "/usr/lib/pymodules/python2.7/openerp/addons/base/ir/ir_model.py", line 967, in _update 
res_id = model_obj.create(cr, uid, values, context=context) 
    File "/usr/lib/pymodules/python2.7/openerp/addons/base/ir/ir_ui_view.py", line 103, in create 
return super(view, self).create(cr, uid, values, context) 
    File "/usr/lib/pymodules/python2.7/openerp/osv/orm.py", line 4493, in create 
self._validate(cr, user, [id_new], context) 
    File "/usr/lib/pymodules/python2.7/openerp/osv/orm.py", line 1561, in _validate 
raise except_orm('ValidateError', '\n'.join(error_msgs)) except_orm: ('ValidateError', u'Error occurred while validating the field(s) arch: Invalid XML for View Architecture!') 

如果我空在wizard.xml文件中的「拱」標籤,然後在服務器不提高任何錯誤。但我不明白我的架構有什麼問題。

感謝您的幫助:)

+0

請添加完整的追蹤或日誌 – OmaL

回答

1

簡短的回答

確保你的XML文件保存使用UTF-8編碼。一個encoding屬性添加到您的XML定義:

<?xml version="1.0" encoding="utf-8"?> 

希望這有助於。

詳細

一般說來,數據的在OpenERP的驗證主要是由方法每一個模型的_constraints屬性設置處理。在你的情況下,你嘗試創建一個新的ir.ui.view對象時出錯。縱觀base/ir/ir_ui>view.py文件,你可以看到followng:我們剛纔一個約束定義,它是由_check_xml方法評估

_constraints = [ 
    (_check_xml, 'Invalid XML for View Architecture!', ['arch']) 
] 

這裏。看看這種方法,你可以看到,除了XML本身的有效性之外,還對編碼進行了測試。這個測試在OpenERP 6.0中不存在。這意味着您的視圖可能會在OpenERP 6.0下正確呈現。

如果您想要,您可以通過在view類的__check_xml方法中放置斷點來進一步調查。

+0

嗨安德烈,感謝您的答案。 我添加了編碼,但沒有任何更改... 錯誤消息不是「視圖體系結構的無效XML」,因爲_check_xml函數會觸發。但它來自orm的_validate函數。我要檢查這個功能。 感謝您的幫助無論如何;) –

+0

好的,但你的堆棧跟蹤顯示「無效的XML視圖架構」:) –

1

更改您的型號名稱的意思是,你想要把它

<field name="model">test.wizard</field> 

點擊here給類的名字!