1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # Copyright (C) 2010 OpenERP s.a. (<http://www.openerp.com>).
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU Affero General Public License as
8 # published by the Free Software Foundation, either version 3 of the
9 # License, or (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU Affero General Public License for more details.
16 # You should have received a copy of the GNU Affero General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 ##############################################################################
25 from osv import fields,osv
27 # Simple base class for wizards that wish to use random images on the left
29 class wizard_screen(osv.osv_memory):
30 _name = 'ir.wizard.screen'
32 def _get_image(self, cr, uid, context=None):
33 path = os.path.join('base','res','config_pixmaps','%d.png'%random.randrange(1,4))
34 image_file = file_data = tools.file_open(path,'rb')
36 file_data = image_file.read()
37 return base64.encodestring(file_data)
41 def _get_image_fn(self, cr, uid, ids, name, args, context=None):
42 image = self._get_image(cr, uid, context)
43 return dict.fromkeys(ids, image) # ok to use .fromkeys() as the image is same for all
46 'config_logo': fields.function(_get_image_fn, string='Image', type='binary', method=True),
50 'config_logo': _get_image
53 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: