[MERGE] base: review and cleanup of Administration menus and view (bis) - missing wizard_screen file
bzr revid: odo@openerp.com-20101004152719-d619p9itr4q4lyr8
This commit is contained in:
commit
24f82590fa
|
@ -0,0 +1,48 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (C) 2010 OpenERP s.a. (<http://www.openerp.com>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
import base64
|
||||
import os
|
||||
import random
|
||||
|
||||
import tools
|
||||
from osv import fields,osv
|
||||
|
||||
# Simple base class for wizards that wish to use random images on the left
|
||||
# side of the form.
|
||||
class wizard_screen(osv.osv_memory):
|
||||
_name = 'ir.wizard.screen'
|
||||
|
||||
def _get_image(self, cr, uid, context=None):
|
||||
path = os.path.join('base','res','config_pixmaps','%d.png'%random.randrange(1,4))
|
||||
file_data = tools.file_open(path,'rb').read()
|
||||
return base64.encodestring(file_data)
|
||||
|
||||
def _get_image_fn(self, cr, uid, ids, name, args, context=None):
|
||||
image = self._get_image(cr, uid, context)
|
||||
return dict.fromkeys(ids, image) # ok to use .fromkeys() as the image is same for all
|
||||
|
||||
_columns = {
|
||||
'config_logo': fields.function(_get_image_fn, string='Image', type='binary', method=True),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'config_logo': _get_image
|
||||
}
|
||||
wizard_screen()
|
Loading…
Reference in New Issue