~openerp-commiter/openobject-addons/stable-sja-branch

« back to all changes in this revision

Viewing changes to personal_base/wizard/after_login.py

  • Committer: sja-axelor
  • Date: 2009-10-13 09:52:57 UTC
  • Revision ID: suniljagyasi@gmail.com-20091013095257-8u26ww0r20z9y6ey
add

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- encoding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
4
# Copyright (c) 2007-2008 Sandas. (http://www.sandas.eu) All Rights Reserved.
 
5
#
 
6
# WARNING: This program as such is intended to be used by professional
 
7
# programmers who take the whole responsability of assessing all potential
 
8
# consequences resulting from its eventual inadequacies and bugs
 
9
# End users who are looking for a ready-to-use solution with commercial
 
10
# garantees and support are strongly adviced to contract a Free Software
 
11
# Service Company
 
12
#
 
13
# This program is Free Software; you can redistribute it and/or
 
14
# modify it under the terms of the GNU General Public License
 
15
# as published by the Free Software Foundation; either version 2
 
16
# of the License, or (at your option) any later version.
 
17
#
 
18
# This program is distributed in the hope that it will be useful,
 
19
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
20
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
21
# GNU General Public License for more details.
 
22
#
 
23
# You should have received a copy of the GNU General Public License
 
24
# along with this program; if not, write to the Free Software
 
25
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
26
#
 
27
############################################################
 
28
 
 
29
import wizard
 
30
import pooler
 
31
import netsvc
 
32
 
 
33
def _after_login(self, cr, uid, data, context):
 
34
    user_pool = pooler.get_pool(cr.dbname).get('res.users')
 
35
    action_pool = pooler.get_pool(cr.dbname).get('personal.base.action.login')
 
36
    wizard_pool = pooler.get_pool(cr.dbname).get('ir.actions.wizard')
 
37
    for id in action_pool.search(cr, uid, []):
 
38
        action = action_pool.browse(cr, uid, id)
 
39
        if action.action_id.type == 'ir.actions.wizard':
 
40
            my_wizard = wizard_pool.browse(cr, uid, action.action_id.id)
 
41
            service = netsvc.LocalService('wizard.' + my_wizard.wiz_name)
 
42
            service.execute(cr.dbname, uid, {"form":{}})
 
43
    
 
44
    res = user_pool.search(cr, uid, [])
 
45
    user = user_pool.browse(cr, uid, res[0])
 
46
    if user.first_login:
 
47
        user_pool.write(cr, uid, uid, {'first_login': False})
 
48
            
 
49
    return {}
 
50
 
 
51
class wizard_after_login(wizard.interface):
 
52
    states = {
 
53
        'init' : {
 
54
            'actions' : [],
 
55
            'result': {'type': 'action', 'action':_after_login, 'state':'end'}
 
56
        },
 
57
    }
 
58
wizard_after_login("personal.base.wizard.after_login")