I created a wizard that works perfectly on the web client, but not on the gui. It loads the first form fine, but when you click the button to go next or previous, nothing happens. I'm pretty sure all my actions and states are defined perfectly. The funny thing is it works perfect on the web client. Any help would be much appreciated. Here is the code for my wizard.
view_form_material_type = """<?xml version="1.0"?> <form string="Setup"> <image name="gtk-dialog-info"/> <group> <separator string="Select a Type" colspan="2"/> <newline/> <field align="0.0" name="material_type" colspan="2"/> <newline/> <label string="Start by selecting a material type. The next form will load all matching alloys from the selected type." colspan="2" align="0.0"/> <newline/> <separator string="Generated Label" colspan="2"/> <newline/> <field name="generated_label" colspan="2"/> </group> </form> """ view_form_material_alloy = """<?xml version="1.0"?> <form string="Setup"> <image name="gtk-dialog-info"/> <group> <separator string="Select a Alloy" colspan="2"/> <newline/> <field align="0.0" name="material_alloy" colspan="2"/> <newline/> <label string="Now select a material alloy. The next form will load all matching grades from your selected alloy." colspan="2" align="0.0"/> <newline/> <separator string="Generated Label" colspan="2"/> <newline/> <field name="generated_label" colspan="2"/> </group> </form> """ view_form_material_grade = """<?xml version="1.0"?> <form string="Setup"> <image name="gtk-dialog-info"/> <group> <separator string="Select a Grade" colspan="2"/> <newline/> <field align="0.0" name="material_grade"/> <newline/> <label string="Now select a material grade. The next form will load all matching stocks from your selected grade." colspan="2" align="0.0"/> <newline/> <separator string="Generated Label" colspan="2"/> <newline/> <field name="generated_label" colspan="2"/> </group> </form> """ view_form_material_stock = """<?xml version="1.0"?> <form string="Setup"> <image name="gtk-dialog-info"/> <group> <separator string="Select a Stock" colspan="2"/> <newline/> <field align="0.0" name="material_stock" colspan="2"/> <newline/> <label string="Now select a material stock. The next form will load all matching shapes from your selected stock." colspan="2" align="0.0"/> <newline/> <separator string="Generated Label" colspan="2"/> <newline/> <field name="generated_label" colspan="2" /> </group> </form> """ view_form_material_shape = """<?xml version="1.0"?> <form string="Setup"> <image name="gtk-dialog-info"/> <group> <separator string="Select a Shape" colspan="2"/> <newline/> <field align="0.0" name="material_shape"/> <newline/> <label string="Now select a material shape. This will be your last selection" colspan="2" align="0.0"/> <newline/> <separator string="Generated Label" colspan="2"/> <newline/> <field name="generated_label" colspan="2"/> </group> </form> """ class wizard_material(wizard.interface): def _update_shapes(self, cr, uid, data, context): generated_label = data['form']['material_type'] + " -> " + data['form']['material_alloy'] + " -> " + data['form']['material_grade'] + " -> " + data['form']['material_stock'] shape_obj=pooler.get_pool(cr.dbname).get('material.shape') ids=shape_obj.search(cr, uid, [('material_stock_id', '=', data['form']['material_stock'])]) if not ids: return {'generated_label':generated_label} res=[(m.name, m.name) for m in shape_obj.browse(cr, uid, ids, context=context)] res.sort() self.fields['material_shape']['selection'] = res self.fields['material_shape']['default'] = res[0] return {'generated_label':generated_label} def _update_stocks(self, cr, uid, data, context): generated_label = data['form']['material_type'] + " -> " + data['form']['material_alloy'] + " -> " + data['form']['material_grade'] stock_obj=pooler.get_pool(cr.dbname).get('material.stock') ids=stock_obj.search(cr, uid, [('material_grade_id', '=', data['form']['material_grade'])]) if not ids: return {'generated_label':generated_label} res=[(m.name, m.name) for m in stock_obj.browse(cr, uid, ids, context=context)] res.sort() self.fields['material_stock']['selection'] = res self.fields['material_stock']['default'] = res[0] return {'generated_label':generated_label} def _update_grades(self, cr, uid, data, context): generated_label = data['form']['material_type'] + " -> " + data['form']['material_alloy'] grade_obj=pooler.get_pool(cr.dbname).get('material.grade') ids=grade_obj.search(cr, uid, [('material_alloy_id', '=', data['form']['material_alloy']), ('material_type_id', '=', data['form']['material_type'])]) if not ids: self.fields['material_grade']['selection'] = [] return {'generated_label':generated_label} res=[(m.name, m.name) for m in grade_obj.browse(cr, uid, ids, context=context)] res.sort() self.fields['material_grade']['selection'] = res self.fields['material_grade']['default'] = res[0] return {'generated_label':generated_label} def _update_alloys(self, cr, uid, data, context): alloy_obj=pooler.get_pool(cr.dbname).get('material.alloy') ids=alloy_obj.search(cr, uid, [('material_type_id', '=', data['form']['material_type'])]) if not ids: self.fields['material_alloy']['selection'] = [] return {'generated_label':data['form']['material_type']} res=[(m.name, m.name) for m in alloy_obj.browse(cr, uid, ids, context=context)] res.sort() self.fields['material_alloy']['selection'] = res self.fields['material_alloy']['default'] = res[0] return {'generated_label':data['form']['material_type']} def _update_types(self, cr, uid, data, context): return {'generated_label':''} def _get_material_types(self, cr, uid, context): module_obj=pooler.get_pool(cr.dbname).get('material.type') ids=module_obj.search(cr, uid, []) res=[(m.name, m.name) for m in module_obj.browse(cr, uid, ids, context=context)] res.sort() return res def _menu(self, cr, uid, data, context): users_obj=pooler.get_pool(cr.dbname).get('res.users') action_obj=pooler.get_pool(cr.dbname).get('ir.actions.act_window') ids=action_obj.search(cr, uid, [('name', '=', 'Menu')]) menu=action_obj.browse(cr, uid, ids)[0] ids=users_obj.search(cr, uid, [('action_id', '=', 'Setup')]) users_obj.write(cr, uid, ids, {'action_id': menu.id}) ids=users_obj.search(cr, uid, [('menu_id', '=', 'Setup')]) users_obj.write(cr, uid, ids, {'menu_id': menu.id}) return { 'name': menu.name, 'type': menu.type, 'view_id': (menu.view_id and\ (menu.view_id.id, menu.view_id.name)) or False, 'domain': menu.domain, 'res_model': menu.res_model, 'src_model': menu.src_model, 'view_type': menu.view_type, 'view_mode': menu.view_mode, 'views': menu.views, } fields = { 'material_type':{ 'string':'Material Type', 'type':'selection', 'selection':_get_material_types, 'required': True, }, 'material_alloy':{ 'string': 'Material Alloy', 'type':'selection', 'selection':[], 'required': True, }, 'material_grade':{ 'string': 'Material Grade', 'type':'selection', 'selection':[], 'required': True, }, 'material_stock':{ 'string': 'Material Stock', 'type': 'selection', 'selection':[], 'required':True, }, 'material_shape':{ 'string': 'Material Shape', 'type': 'selection', 'selection':[], 'required':True, }, 'generated_label':{ 'string':'Generating Material Label', 'type':'char', 'readonly': True, 'nolabel':1, }, } states = { 'init': { 'actions': [_update_types], 'result': {'type': 'form', 'arch':view_form_material_type, 'fields':fields, 'state': [ #('menu', 'Cancel', 'gtk-cancel'), #('select_material_alloy', 'Next', 'gtk-go-forward', True)] ('menu', 'Cancel'), ('select_material_alloy', 'Next')] } }, 'select_material_alloy':{ 'actions': [_update_alloys], 'result': {'type': 'form', 'arch':view_form_material_alloy, 'fields':fields, 'state':[ ('init', 'Previous', 'gtk-go-back'), ('select_material_grade', 'Next', 'gtk-go-forward', True)] } }, 'select_material_grade':{ 'actions': [_update_grades], 'result': {'type': 'form', 'arch':view_form_material_grade, 'fields':fields, 'state':[ ('select_material_alloy', 'Previous', 'gtk-go-back'), ('select_material_stock', 'Next', 'gtk-go-forward', True)] } }, 'select_material_stock':{ 'actions': [_update_stocks], 'result': {'type': 'form', 'arch': view_form_material_stock, 'fields':fields, 'state':[ ('select_material_grade', 'Previous', 'gtk-go-back'), ('select_material_shape', 'Next', 'gtk-go-forward', True)] } }, 'select_material_shape':{ 'actions': [_update_shapes], 'result': {'type': 'form', 'arch': view_form_material_shape, 'fields':fields, 'state':[ ('select_material_stock', 'Previous', 'gtk-go-back'), ('menu', 'Next', 'gtk-go-forward', True)] } }, 'menu': { 'actions': [], 'result': {'type': 'action', 'action': _menu, 'state': 'end'} }, } wizard_material('material.add.product') -------------------- m2f -------------------- -- http://www.openobject.com/forum/viewtopic.php?p=37143#37143 -------------------- m2f -------------------- _______________________________________________ Tinyerp-users mailing list http://tiny.be/mailman2/listinfo/tinyerp-users
