Odoo Help

0

Need help with wizards

By
Luis Filipe Castanheira
on 5/14/14, 1:05 PM 1,012 views

I'm trying to implement a wizard that will update a form a then (if possible, send a signal to workflow to change status of an object, but that will be for later). I'm  trying and trying, but I'm doing something wrong since I get stuck with this annoying error!

I've got these two files inside the "wizard" folder:
reformulate_wizard.py:
from openerp.osv import osv
from openerp.osv import fields
from openerp.tools.translate import _

class ref_generic_request(osv.osv_memory):
    _name='ref.generic.request'

    _columns = {
        'reformulation_info': fields.text('Reformulation instructions', help='Instructions for the requestor justification the reformulation needs'),
            }

    
    def save_info(self, cr, uid, ids, context=None):
        if 'active_id' in context:
            info=self.browse(cr,uid,ids)[0].reformulation_info
            self.pool.get('project.task').write(cr,uid,context['active_id'],
                                                 {'remaining_hours' : remaining_hrs})
        return {
                'type': 'ir.actions.act_window_close',
         }
ref_generic_request()

reformulate_wizard.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record id="view_reformulate_generic_request_wizard" model="ir.ui.view">
            <field name="name">reformulate_generic_request_wizard.form</field>
            <field name="model">ref.generic.request</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Insert reformulation info" version="7.0">
                    <group colspan="4" >
                        <separator string="bla bla bla here" colspan="4"/>
                        <field name="reformulation_info" string="Reformulation info"/>
                        <newline/>
                    </group>
                    <separator string="" colspan="4" />
                    <group colspan="4" col="6">
                        <button  icon="gtk-cancel" special="cancel" string="Cancel"/>
                        <button  icon="gtk-ok" name="save_info" string="Send to reformulation" type="object" />
                    </group>
               </form>
            </field>
        </record>
        <record id="action_reformulate_generic_request" model="ir.actions.act_window">
            <field name="name">Reformulate Request</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">ref.generic.request</field>
            <field name="view_type">form</field>
            <field name="view_mode">form</field>
            <field name="view_id" ref="view_reformulate_generic_request_wizard"/>
            <field name="target">new</field>
        </record>

        <act_window id="action_reformulate_generic_request"
                name="Reformulate Request"
                res_model="generic.request"
                view_mode="form"
                target="new"
        />

    </data>
</openerp>

And I didn't forget the __init__.py with the "import reformulate_wizard" in it.

I am calling the wizard from my xml view like this (and I guess that's where I'm getting the error):

<button  name="%(reformulate_generic_request_wizard)d" string="Button that calls wizard" type="object" />

In my base folder I'm importing the wizard folder inside the __init__.py:

import parecer
import pedido_generico
import tracing
import wizard


And here is the content of my __openerp__.py (The error might be from the order I'm loading things):


{
    'name': 'Processos UC',
    'version': '0.1',
    'category': 'Tools',
    'description': """
OpenERP Module that implements UC's business processes.""",
    'author': 'Filipe Castanheira',
    'website': 'http://www.uc.pt',
    'depends': ['base','web'],
    'demo': [],
    'test':[],
    #'js': [
    #        'static/js/custom.js',
    #],
    'css': [ 'static/css/uc_css.css' ],
    'update_xml' : [
            'data/action_server.xml',
            'security/security.xml',
            'security/processos_uc_domain_rules.xml',
            'wizard/reformulate_wizard.xml',
            'processos_view.xml',
            'parecer_wkf.xml',
            'pedido_wkf.xml',
            ],
    'data': [
             'security/ir.model.access.csv',
             'data/owner_groups.xml',
             'data/subject_type.xml',
             ],
    'installable': True,
    'images': [],
}

Here is the error message from the server logs.

2014-05-14 16:55:45,182 19742 ERROR may_9 openerp.tools.convert: Parse error in /home/lfc/openerp/v7/addons/processos_uc/processos_view.xml:23:
(...)XML displayed here(...)
Traceback (most recent call last):
  File "/opt/openerp/v7/server/openerp/tools/convert.py", line 847, in parse
    self._tags[rec.tag](self.cr, rec, n)
  File "/opt/openerp/v7/server/openerp/tools/convert.py", line 807, in _tag_record
    f_val = _eval_xml(self,field, self.pool, cr, self.uid, self.idref)
  File "/opt/openerp/v7/server/openerp/tools/convert.py", line 154, in _eval_xml
    for n in node]), idref)
  File "/opt/openerp/v7/server/openerp/tools/convert.py", line 148, in _process
    idref[id]=self.id_get(cr, id)
  File "/opt/openerp/v7/server/openerp/tools/convert.py", line 824, in id_get
    res = self.model_id_get(cr, id_str)
  File "/opt/openerp/v7/server/openerp/tools/convert.py", line 833, in model_id_get
    return model_data_obj.get_object_reference(cr, self.uid, mod, id_str)
  File "/opt/openerp/v7/server/openerp/tools/cache.py", line 18, in lookup
    r = self.lookup(self2, cr, *args)
  File "/opt/openerp/v7/server/openerp/tools/cache.py", line 46, in lookup
    value = d[key] = self.method(self2, cr, *args)
  File "/opt/openerp/v7/server/openerp/addons/base/ir/ir_model.py", line 869, in get_object_reference
    data_id = self._get_id(cr, uid, module, xml_id)
  File "/opt/openerp/v7/server/openerp/tools/cache.py", line 18, in lookup
    r = self.lookup(self2, cr, *args)
  File "/opt/openerp/v7/server/openerp/tools/cache.py", line 46, in lookup
    value = d[key] = self.method(self2, cr, *args)
  File "/opt/openerp/v7/server/openerp/addons/base/ir/ir_model.py", line 862, in _get_id
    raise ValueError('No such external ID currently defined in the system: %s.%s' % (module, xml_id))
ValueError: No such external ID currently defined in the system: processos_uc.reformulate_generic_request_wizard
2014-05-14 16:55:45,186 19742 ERROR may_9 openerp.netsvc: No such external ID currently defined in the system: processos_uc.reformulate_generic_request_wizard
Traceback (most recent call last):
  File "/opt/openerp/v7/server/openerp/netsvc.py", line 292, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/opt/openerp/v7/server/openerp/service/web_services.py", line 433, in dispatch
    return fn(*params)
  File "/opt/openerp/v7/server/openerp/service/web_services.py", line 444, in exp_authenticate
    res_users = pooler.get_pool(db).get('res.users')
  File "/opt/openerp/v7/server/openerp/pooler.py", line 49, in get_pool
    return get_db_and_pool(db_name, force_demo, status, update_module)[1]
  File "/opt/openerp/v7/server/openerp/pooler.py", line 33, in get_db_and_pool
    registry = RegistryManager.get(db_name, force_demo, status, update_module)
  File "/opt/openerp/v7/server/openerp/modules/registry.py", line 192, in get
    update_module)
  File "/opt/openerp/v7/server/openerp/modules/registry.py", line 218, in new
    openerp.modules.load_modules(registry.db, force_demo, status, update_module)
  File "/opt/openerp/v7/server/openerp/modules/loading.py", line 350, in load_modules
    force, status, report, loaded_modules, update_module)
  File "/opt/openerp/v7/server/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 "/opt/openerp/v7/server/openerp/modules/loading.py", line 187, in load_module_graph
    load_update_xml(module_name, idref, mode)
  File "/opt/openerp/v7/server/openerp/modules/loading.py", line 74, in <lambda>
    load_update_xml = lambda *args: _load_data(cr, *args, kind='update_xml')
  File "/opt/openerp/v7/server/openerp/modules/loading.py", line 124, in _load_data
    tools.convert_xml_import(cr, module_name, fp, idref, mode, noupdate, report)
  File "/opt/openerp/v7/server/openerp/tools/convert.py", line 954, in convert_xml_import
    obj.parse(doc.getroot())
  File "/opt/openerp/v7/server/openerp/tools/convert.py", line 847, in parse
    self._tags[rec.tag](self.cr, rec, n)
  File "/opt/openerp/v7/server/openerp/tools/convert.py", line 807, in _tag_record
    f_val = _eval_xml(self,field, self.pool, cr, self.uid, self.idref)
  File "/opt/openerp/v7/server/openerp/tools/convert.py", line 154, in _eval_xml
    for n in node]), idref)
  File "/opt/openerp/v7/server/openerp/tools/convert.py", line 148, in _process
    idref[id]=self.id_get(cr, id)
  File "/opt/openerp/v7/server/openerp/tools/convert.py", line 824, in id_get
    res = self.model_id_get(cr, id_str)
  File "/opt/openerp/v7/server/openerp/tools/convert.py", line 833, in model_id_get
    return model_data_obj.get_object_reference(cr, self.uid, mod, id_str)
  File "/opt/openerp/v7/server/openerp/tools/cache.py", line 18, in lookup
    r = self.lookup(self2, cr, *args)
  File "/opt/openerp/v7/server/openerp/tools/cache.py", line 46, in lookup
    value = d[key] = self.method(self2, cr, *args)
  File "/opt/openerp/v7/server/openerp/addons/base/ir/ir_model.py", line 869, in get_object_reference
    data_id = self._get_id(cr, uid, module, xml_id)
  File "/opt/openerp/v7/server/openerp/tools/cache.py", line 18, in lookup
    r = self.lookup(self2, cr, *args)
  File "/opt/openerp/v7/server/openerp/tools/cache.py", line 46, in lookup
    value = d[key] = self.method(self2, cr, *args)
  File "/opt/openerp/v7/server/openerp/addons/base/ir/ir_model.py", line 862, in _get_id
    raise ValueError('No such external ID currently defined in the system: %s.%s' % (module, xml_id))
ValueError: No such external ID currently defined in the system: processos_uc.reformulate_generic_request_wizard

 


Any help is more than welcome!

1
Jaakko Komulainen
On 5/15/14, 7:03 AM

Your button type needs to be "action" when executing an action and the name should be the id of the action to trigger.

 See: https://doc.openerp.com/6.0/developer/2_6_views_events/views/design_element/#button

1
Kazim Mirza
On 5/15/14, 10:29 AM

<button  name="%(reformulate_generic_request_wizard)d" string="Button that calls wizard" type="action" />

 

you have to write  action_reformulate_generic_request in "%(reformulate_generic_request_wizard)d"

1

Thanks for your answer. It solved that problem (I wasn't reading correctly the code, and I read it many times, believe me!).

Now I'm getting this strange error message when I click my button (I say strange because I don't have any occurrence of '111' anywhere in my code. And I did a `grep -R 111 *` to be sure!):

2014-05-15 14:00:49,986 3108 ERROR may_9 openerp.osv.osv: Uncaught exception
Traceback (most recent call last):
  File "/opt/openerp/v7/server/openerp/osv/osv.py", line 131, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/opt/openerp/v7/server/openerp/osv/osv.py", line 197, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/opt/openerp/v7/server/openerp/osv/osv.py", line 185, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
AttributeError: 'generic_request' object has no attribute '111'
2014-05-15 14:00:49,987 3108 ERROR may_9 openerp.netsvc: 'generic_request' object has no attribute '111'
Traceback (most recent call last):
  File "/opt/openerp/v7/server/openerp/netsvc.py", line 292, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/opt/openerp/v7/server/openerp/service/web_services.py", line 626, in dispatch
    res = fn(db, uid, *params)
  File "/opt/openerp/v7/server/openerp/osv/osv.py", line 188, in execute_kw
    return self.execute(db, uid, obj, method, *args, **kw or {})
  File "/opt/openerp/v7/server/openerp/osv/osv.py", line 131, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/opt/openerp/v7/server/openerp/osv/osv.py", line 197, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/opt/openerp/v7/server/openerp/osv/osv.py", line 185, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
AttributeError: 'generic_request' object has no attribute '111'


Any idea of wath might be causing this exception?

 

---------------------------------------------------------------

Ok, got it! I had the wrong name in the button, plus the wrong type!

<button  name="%(action_reformulate_generic_request)d" string="Button that calls wizard" type="action" />

Solved it, and it is working fine now. Thanks, all for your help!

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 5/14/14, 1:05 PM
Seen: 1012 times
Last updated: 3/16/15, 8:10 AM