1
votes

I'm learning how to develop modules on OpenERP v7. Everthing OK until I tried to add a wizard: OpenERP won't accept my View architecture and I can't figure out why!

Module Architecture is:

  • _init.py_ (where I import module.py and wizard)
  • _openerp.py_ (dependencies: Base; data: view/view.xml ; wizard/wizard.xml)
  • module.py (where I've got the main code and everything works fine)
  • view/view.xml (Main view going with the main code, no problem)
  • wizard/_init.py_ (import wizard)
  • wizard/wizard.py (code below)
  • wizard/wizard.xml (code below)

Here is the wizard.py file:

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

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

and here is the wizard.xml file:

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

This is all basic for the moment but I would like to have it working so I can build upon it...

Here is the server traceback:

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!')

If I empty the "arch" tag in the wizard.xml file, then the server doesn't raise any error. But I can't understand what's wrong with my architecture.

Thanks for your help :)

2
pls add the complete traceback or logOmaL

2 Answers

1
votes

Short answer

Make sure your XML file is saved with utf-8 encoding. Add an encoding attribute to your xml definition:

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

Hope this helps.

Details

Generally speaking, the validation of data in OpenERP is mainly handled by method set in the _constraints attribute of every model. In your case you have the error when trying to create a new ir.ui.view object. Looking at the base/ir/ir_ui>view.py file you can see the followng:

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

Here we have just one constraint defined and it is evaluated by the _check_xml method. Looking at this method you can see that apart from the validity of the XML itself a test of the encoding is made too. This test doesn't exist in OpenERP 6.0. This means tha probably your view will be correctly rendered under OpenERP 6.0.

If you want you can further investigate by putting a breakpoint in the __check_xml method of the view class.

1
votes

Change you model name mean give the name of the class where you want to put it

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

Click here!