585105c3308893cd3e30e6f89a8faca8bfddd505
[odoo/odoo.git] / addons / profile_service / profile_service.py
1 # -*- encoding: utf-8 -*-
2 ##############################################################################
3 #
4 # Copyright (c) 2004-2008 Tiny SPRL (http://tiny.be) All Rights Reserved.
5 #
6 # $Id: __terp__.py 8595 2008-06-16 13:00:21Z stw $
7 #
8 # WARNING: This program as such is intended to be used by professional
9 # programmers who take the whole responsability of assessing all potential
10 # consequences resulting from its eventual inadequacies and bugs
11 # End users who are looking for a ready-to-use solution with commercial
12 # garantees and support are strongly adviced to contract a Free Software
13 # Service Company
14 #
15 # This program is Free Software; you can redistribute it and/or
16 # modify it under the terms of the GNU General Public License
17 # as published by the Free Software Foundation; either version 2
18 # of the License, or (at your option) any later version.
19 #
20 # This program is distributed in the hope that it will be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 # GNU General Public License for more details.
24 #
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write to the Free Software
27 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
28 ###############################################################################
29
30 from osv import fields, osv
31 import pooler
32
33 ##class config_install_extra_modules(osv.osv_memory):
34 ##    _name='config.install_extra_modules'
35 ##    def _get_uninstall_modules(self,cr,uid,context=None):
36 ##        module_obj=self.pool.get('ir.module.module')
37 ##        line_obj=self.pool.get('config.install_extra_modules.line')
38 ##        uninstall_module_ids=module_obj.search(cr,uid,[('state', 'in', ['uninstalled', 'uninstallable'])])
39 ##        res=[]
40 ##        for id in uninstall_module_ids:
41 ##            res.append(line_obj.create(cr,uid,{'module_id':id},context=None))
42 ##        print res
43 ##        return res
44 ##    _columns = {
45 ##        'name':fields.char('Name', size=64),
46 ##        'module_ids':fields.one2many('config.install_extra_modules.line', 'config_id', 'Modules'),
47 ##
48 ##    }
49 ##    _defaults={
50 ##       'module_ids':_get_uninstall_modules
51 ##    }
52 ##    def action_install(self, cr, uid, ids, context=None):
53 ##        res=self.read(cr,uid,ids)[0]
54 ##        mod_obj = self.pool.get('ir.module.module')
55 ##        line_obj=self.pool.get('config.install_extra_modules.line')
56 ##        if 'module_ids' in res:
57 ##            module_ids=res['module_ids']
58 ##            lines=line_obj.read(cr,uid,module_ids)
59 ##            for line in lines:
60 ##                if 'install' in line and 'module_id' and line and line['install']:
61 ##                    mod_obj.download(cr, uid, [line['module_id']], context=context)
62 ##                    cr.commit()
63 ##                    db, pool = pooler.restart_pool(cr.dbname, update_module=True)
64 ##        return {
65 ##                'view_type': 'form',
66 ##                "view_mode": 'form',
67 ##                'res_model': 'ir.module.module.configuration.wizard',
68 ##                'type': 'ir.actions.act_window',
69 ##                'target':'new',
70 ##            }
71 ##
72 ##config_install_extra_modules()
73 #
74 #class config_install_extra_modules_line(osv.osv_memory):
75 #    _name='config.install_extra_modules.line'
76 #    _columns = {
77 #        'name':fields.char('Name', size=64),
78 #        'install':fields.boolean('Install'),
79 #        'config_id': fields.many2one('config.install_extra_modules', 'Configuration Module Wizard'),
80 #        'module_id':fields.many2one('ir.module.module', 'Module',readonly=True,required=True),
81 #
82 #    }
83 #
84 #
85 #config_install_extra_modules_line()
86
87 class config_install_extra_modules(osv.osv_memory):
88     _name='config.install_extra_modules'
89     _columns = {
90         'name':fields.char('Name', size=64),
91         'timesheets_module':fields.boolean('Timesheets Management'),
92         'holidays_module':fields.boolean('Hollidays Management'),
93
94     }
95     def action_cancel(self,cr,uid,ids,conect=None):
96         return {
97                 'view_type': 'form',
98                 "view_mode": 'form',
99                 'res_model': 'ir.module.module.configuration.wizard',
100                 'type': 'ir.actions.act_window',
101                 'target':'new',
102          }
103     def action_install(self, cr, uid, ids, context=None):
104         res=self.read(cr,uid,ids)[0]
105         mod_obj = self.pool.get('ir.module.module')
106         if 'timesheets_module' in res and res['timesheets_module']:
107             ids = mod_obj.search(cr, uid, [('name', '=', 'hr_timesheet')])
108             mod_obj.download(cr, uid, ids, context=context)
109             cr.commit()
110             #db, pool = pooler.restart_pool(cr.dbname, update_module=True)
111         if  'hr_holidays_module' in res and res['hr_holidays_module']:
112             ids = mod_obj.search(cr, uid, [('name', '=', 'hr_holidays')])
113             mod_obj.download(cr, uid, ids, context=context)
114             cr.commit()
115             #db, pool = pooler.restart_pool(cr.dbname, update_module=True)
116         return {
117                 'view_type': 'form',
118                 "view_mode": 'form',
119                 'res_model': 'ir.module.module.configuration.wizard',
120                 'type': 'ir.actions.act_window',
121                 'target':'new',
122             }
123
124 config_install_extra_modules()
125
126 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
127