[IMP] Renamed photo field to avatar. Propagated changes. Modified user view: photo is now on the left of users tab.
bzr revid: tde@openerp.com-20120221152910-mw9zm3fnbyxbmqq8
This commit is contained in:
parent
8413a61979
commit
dc6b84ab97
|
@ -93,8 +93,8 @@
|
|||
<field name="menu_tips" readonly="0" groups="base.group_no_one"/>
|
||||
</group>
|
||||
<group col="2" colspan="1">
|
||||
<separator string="Photo" colspan="2"/>
|
||||
<field name="photo" widget='image' nolabel="1" colspan="2"/>
|
||||
<separator string="Avatar" colspan="2"/>
|
||||
<field name="avatar" widget='image' nolabel="1" colspan="2"/>
|
||||
</group>
|
||||
</group>
|
||||
<group name="default_filters" colspan="2" col="2">
|
||||
|
@ -124,20 +124,19 @@
|
|||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="User">
|
||||
<group colspan="4" col="6">
|
||||
<group colspan="4" col="7">
|
||||
<!-- Second nested group to avoid misalignment with email prefs groups
|
||||
in simplified view -->
|
||||
<group colspan="6" col="6">
|
||||
<group colspan="7" col="7">
|
||||
<group col="2" colspan="1">
|
||||
<separator string="Avatar" colspan="2"/>
|
||||
<field name="avatar_mini" widget='image' nolabel="1" colspan="2"/>
|
||||
</group>
|
||||
<group col="3" colspan="2">
|
||||
<separator string="Preferences" colspan="3"/>
|
||||
<group col="2" colspan="2">
|
||||
<field name="context_lang"/>
|
||||
<field name="context_tz"/>
|
||||
<field name="menu_tips"/>
|
||||
</group>
|
||||
<group name="gr_photo" col="2" colspan="1">
|
||||
<field name="photo" widget='image' nolabel="1" colspan="2"/>
|
||||
</group>
|
||||
<field name="context_lang"/>
|
||||
<field name="context_tz"/>
|
||||
<field name="menu_tips"/>
|
||||
</group>
|
||||
<group name="default_filters" colspan="2" col="2">
|
||||
<separator string="Default Filters" colspan="2"/>
|
||||
|
@ -149,7 +148,7 @@
|
|||
<field domain="[('usage','=','menu')]" name="menu_id" required="True"/>
|
||||
</group>
|
||||
</group>
|
||||
<group colspan="6" col="2">
|
||||
<group colspan="7" col="2">
|
||||
<separator string="Email Preferences" colspan="2"/>
|
||||
<field name="user_email" widget="email"/>
|
||||
<field name="signature"/>
|
||||
|
|
|
@ -203,21 +203,25 @@ class users(osv.osv):
|
|||
self.write(cr, uid, ids, {'groups_id': [(4, extended_group_id)]}, context=context)
|
||||
return True
|
||||
|
||||
def _get_photo_mini(self, cr, uid, ids, name, args, context=None):
|
||||
def _get_avatar_mini(self, cr, uid, ids, name, args, context=None):
|
||||
result = {}
|
||||
for obj in self.browse(cr, uid, ids, context=context):
|
||||
if not obj.photo:
|
||||
if not obj.avatar:
|
||||
result[obj.id] = False
|
||||
continue
|
||||
|
||||
image_stream = io.BytesIO(obj.photo.decode('base64'))
|
||||
image_stream = io.BytesIO(obj.avatar.decode('base64'))
|
||||
img = Image.open(image_stream)
|
||||
img.thumbnail((120, 100), Image.ANTIALIAS)
|
||||
img.thumbnail((180, 150), Image.ANTIALIAS)
|
||||
img_stream = StringIO.StringIO()
|
||||
img.save(img_stream, "JPEG")
|
||||
result[obj.id] = img_stream.getvalue().encode('base64')
|
||||
return result
|
||||
|
||||
def _set_avatar_mini(self, cr, uid, id, name, value, args, context=None):
|
||||
self.write(cr, uid, [id], {'avatar': value}, context=context)
|
||||
return True
|
||||
|
||||
def _get_interface_type(self, cr, uid, ids, name, args, context=None):
|
||||
"""Implementation of 'view' function field getter, returns the type of interface of the users.
|
||||
@param field_name: Name of the field
|
||||
|
@ -258,10 +262,10 @@ 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),
|
||||
'photo': fields.binary('User Photo'),
|
||||
'photo_mini': fields.function(_get_photo_mini, string='User Photo Mini', type="binary",
|
||||
'avatar': fields.binary('User Avatar'),
|
||||
'avatar_mini': fields.function(_get_avatar_mini, fnct_inv=_set_avatar_mini, string='User Avatar Mini', type="binary",
|
||||
store = {
|
||||
'res.users': (lambda self, cr, uid, ids, c={}: ids, ['photo'], 10),
|
||||
'res.users': (lambda self, cr, uid, ids, c={}: ids, ['avatar'], 10),
|
||||
}),
|
||||
'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."),
|
||||
|
@ -374,14 +378,14 @@ class users(osv.osv):
|
|||
pass
|
||||
return result
|
||||
|
||||
def _get_photo(self, cr, uid, context=None):
|
||||
photo_path = openerp.modules.get_module_resource('base','images','photo.png')
|
||||
return open(photo_path, 'rb').read().encode('base64')
|
||||
def _get_avatar(self, cr, uid, context=None):
|
||||
avatar_path = openerp.modules.get_module_resource('base','images','photo.png')
|
||||
return open(avatar_path, 'rb').read().encode('base64')
|
||||
|
||||
_defaults = {
|
||||
'password' : '',
|
||||
'context_lang': 'en_US',
|
||||
'photo': _get_photo,
|
||||
'avatar': _get_avatar,
|
||||
'active' : True,
|
||||
'menu_id': _get_menu,
|
||||
'company_id': _get_company,
|
||||
|
|
Loading…
Reference in New Issue