[IMP] add new handler for addons configuration, corresponding menu item
authorXavier Morel <xmo@tinyerp.com>
Thu, 3 Dec 2009 12:31:10 +0000 (13:31 +0100)
committerXavier Morel <xmo@tinyerp.com>
Thu, 3 Dec 2009 12:31:10 +0000 (13:31 +0100)
bzr revid: xmo@tinyerp.com-20091203123110-r1v2vycpe92bvvxc

bin/addons/base/ir/ir.xml
bin/addons/base/ir/ir_actions.py

index ea42739..60d63b3 100644 (file)
         </record>
         <menuitem action="action_config_wizard_form" id="menu_config_module" parent="base.next_id_11"/>
 
+        <record id="action_start_configurator" model="ir.actions.server">
+          <field name="name">Start Configuration</field>
+          <field name="model_id" ref="model_ir_actions_configurator"/>
+          <field name="state">code</field>
+          <field name="code">action = self.next(cr, uid)</field>
+        </record>
+        <menuitem action="action_start_configurator" id="menu_configurator_module" parent="next_id_11" type="server"/>
     </data>
 </openerp>
index dcdbf31..f8c6dfa 100644 (file)
@@ -812,5 +812,42 @@ class ir_actions_configuration_wizard(osv.osv_memory):
         return self.button_next(cr, uid, ids, context)
 ir_actions_configuration_wizard()
 
+class ir_actions_configurator(osv.osv_memory):
+    _name = 'ir.actions.configurator'
+    logger = netsvc.Logger()
+    def next_action(self, cr, uid, context=None):
+        todos = self.pool.get('ir.actions.todo')
+        self.logger.notifyChannel('actions', netsvc.LOG_INFO,
+                                  'getting next %s' % todos)
+        active_todos = todos.search(cr, uid,
+                                [('type','=','configure'),
+                                 ('state', '=', 'open'),
+                                 ('active','=',True)],
+                                limit=1, context=None)
+        if active_todos:
+            return todos.browse(cr, uid, active_todos[0], context=None)
+        return None
+
+    def next(self, cr, uid):
+        self.logger.notifyChannel('actions', netsvc.LOG_INFO,
+                                  'getting next operation')
+        next = self.next_action(cr, uid)
+        self.logger.notifyChannel('actions', netsvc.LOG_INFO,
+                                  'next action is %s' % next)
+        if next:
+            self.pool.get('ir.actions.todo').write(cr, uid, next.id, {
+                    'state':'done',
+                    }, context=None)
+            action = next.action_id
+            return {
+                'view_mode': action.view_mode,
+                'view_type': action.view_type,
+                'view_id': action.view_id and [action.view_id.id] or False,
+                'res_model': action.res_model,
+                'type': action.type,
+                'target': action.target,
+                }
+        return {'type': 'ir.actions.act_window_close'}
+ir_actions_configurator()
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: