import wizard
import pooler

def _check_sections(self, cr, uid, data, context):
    pool = pooler.get_pool(cr.dbname)
    data_obj = pool.get('ir.model.data')
    sec_obj = pool.get('crm.case.section')
    bug_id = sec_obj.search(cr, uid, [('code','=','BugSup')])
    if not bug_id:
        raise wizard.except_wizard(_('Error !'),
            _('You did not installed the Bug Tracking when you configured the crm module.' \
              '\nyou must create a section with the code \'BugSup\'.'
              ))
    else:
        id1 = data_obj._get_id(cr, uid, 'crm', 'crm_case_form_view')
        if id1:
            id1 = data_obj.browse(cr, uid, id1, context=context).res_id
        return {
            'domain':"[('section_id.name','=','Bug Tracking')]",
            'name': _('New Bug'),
            'view_type': 'form',
            'view_mode': 'form',
            'res_model': 'crm.case',
            'view_id': False,
            'views': [(id1,'form')],
            'type': 'ir.actions.act_window',
            }
        
class check_section(wizard.interface):
    states = {
        'init': {
            'actions': [],
            'result': {'type': 'action', 'action':_check_sections, 'state' : 'end'}
        },
    }
check_section('portal.crm.check.section')

# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
