[IMP] Reordered imports (alaphabetical order); avatar_stored->avatar_big, clearer field name
bzr revid: tde@openerp.com-20120323110521-rna7hh5alr0as04c
This commit is contained in:
parent
d67e232806
commit
10eba844ba
|
@ -25,22 +25,21 @@ from functools import partial
|
|||
|
||||
import pytz
|
||||
|
||||
import netsvc
|
||||
import pooler
|
||||
import tools
|
||||
from osv import fields,osv
|
||||
from osv.orm import browse_record
|
||||
from service import security
|
||||
from tools.translate import _
|
||||
import openerp
|
||||
import openerp.exceptions
|
||||
import io, StringIO
|
||||
from lxml import etree
|
||||
from lxml.builder import E
|
||||
|
||||
|
||||
import io, StringIO
|
||||
import netsvc
|
||||
import openerp
|
||||
import openerp.exceptions
|
||||
from osv import fields,osv
|
||||
from osv.orm import browse_record
|
||||
from PIL import Image
|
||||
import pooler
|
||||
import random
|
||||
from service import security
|
||||
import tools
|
||||
from tools.translate import _
|
||||
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -219,10 +218,10 @@ class users(osv.osv):
|
|||
return dict(zip(ids, ['extended' if user in extended_users else 'simple' for user in ids]))
|
||||
|
||||
def onchange_avatar(self, cr, uid, ids, value, context=None):
|
||||
return {'value': {'avatar_stored': self._avatar_resize(cr, uid, value, 540, 450, context=context), 'avatar': self._avatar_resize(cr, uid, value, context=context) } }
|
||||
return {'value': {'avatar_big': self._avatar_resize(cr, uid, value, 540, 450, context=context), 'avatar': self._avatar_resize(cr, uid, value, context=context) } }
|
||||
|
||||
def _set_avatar(self, cr, uid, id, name, value, args, context=None):
|
||||
return self.write(cr, uid, [id], {'avatar_stored': self._avatar_resize(cr, uid, value, 540, 450, context=context)}, context=context)
|
||||
return self.write(cr, uid, [id], {'avatar_big': self._avatar_resize(cr, uid, value, 540, 450, context=context)}, context=context)
|
||||
|
||||
def _avatar_resize(self, cr, uid, avatar, height=180, width=150, context=None):
|
||||
image_stream = io.BytesIO(avatar.decode('base64'))
|
||||
|
@ -235,8 +234,8 @@ class users(osv.osv):
|
|||
def _get_avatar(self, cr, uid, ids, name, args, context=None):
|
||||
result = dict.fromkeys(ids, False)
|
||||
for user in self.browse(cr, uid, ids, context=context):
|
||||
if user.avatar_stored:
|
||||
result[user.id] = self._avatar_resize(cr, uid, user.avatar_stored, context=context)
|
||||
if user.avatar_big:
|
||||
result[user.id] = self._avatar_resize(cr, uid, user.avatar_big, context=context)
|
||||
return result
|
||||
|
||||
def _set_new_password(self, cr, uid, id, name, value, args, context=None):
|
||||
|
@ -268,11 +267,11 @@ class users(osv.osv):
|
|||
"otherwise leave empty. After a change of password, the user has to login again."),
|
||||
'user_email': fields.char('Email', size=64),
|
||||
'signature': fields.text('Signature', size=64),
|
||||
'avatar_stored': fields.binary('Stored avatar', help="This field holds the image used as avatar for the user. The avatar field is used as an interface to access this field. The image is base64 encoded, and PIL-supported. It is stored as a 540x450 px image, incase a bigger image must be used."),
|
||||
'avatar_big': fields.binary('Big-sized avatar', help="This field holds the image used as avatar for the user. The avatar field is used as an interface to access this field. The image is base64 encoded, and PIL-supported. It is stored as a 540x450 px image, in case a bigger image must be used."),
|
||||
'avatar': fields.function(_get_avatar, fnct_inv=_set_avatar, string='Avatar', type="binary",
|
||||
store = {
|
||||
'res.users': (lambda self, cr, uid, ids, c={}: ids, ['avatar_stored'], 10),
|
||||
}, help="Image used as avatar for the user. It is automatically resized as a 180x150 px image. This field serves as an interface to the avatar_stored field."),
|
||||
'res.users': (lambda self, cr, uid, ids, c={}: ids, ['avatar_big'], 10),
|
||||
}, help="Image used as avatar for the user. It is automatically resized as a 180x150 px image. This field serves as an interface to the avatar_big field."),
|
||||
'active': fields.boolean('Active'),
|
||||
'action_id': fields.many2one('ir.actions.actions', 'Home Action', help="If specified, this action will be opened at logon for this user, in addition to the standard menu."),
|
||||
'menu_id': fields.many2one('ir.actions.actions', 'Menu Action', help="If specified, the action will replace the standard menu for this user."),
|
||||
|
|
Loading…
Reference in New Issue