Thibault Delavallée (OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-user_img-tde into lp:openobject-addons.
Requested reviews:
OpenERP Core Team (openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-user_img-tde/+merge/97205
-- need server branch lp:~openerp-dev/openobject-server/trunk-user_img-tde if
not merged--
HR photo specs
==============
This revision modifies the photo for HR employees. Two fields now exist in the
hr.employee model:
- photo_big, a binary field holding the image. It is base-64 encoded, and
PIL-supported. It is automatically resized as an 540x450 px image.
- photo, a functional binary field holding an automatically resized version of
the photo. Dimensions of the resized photo are 180x150. This field is used as
an inteface to get and set the employee photo.
When changing the photo through the photo function field, the new image is
automatically resized to 540x450, and stored in the photo_big field. This
triggers the function field, that will compute a 180x150 resized version of the
image.
Employee photo should be used only when dealing with employees, using the photo
field. When dealing with users, use the res.users avatar field instead.
CRM kanban avatar specs
=======================
Kanban view of opportunities has been updated to use the newly-introduced
avatar_mini field of res.users. The avatar is placed in the right-side of the
containing kanban box. CSS file has been added to hold the css definitions
necessary to update the boxes.
Task kanban avatar specs
========================
Kanban view of tasks has been updated to use the newly-introduced avatar_mini
field of res.users. The avatar is placed in the right-side of the containing
kanban box. CSS file has been added to hold the css definitions necessary to
update the boxes.
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-user_img-tde/+merge/97205
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/trunk-user_img-tde.
=== modified file 'crm/crm_lead_view.xml'
--- crm/crm_lead_view.xml 2012-03-21 16:29:56 +0000
+++ crm/crm_lead_view.xml 2012-03-23 10:36:21 +0000
@@ -304,7 +304,10 @@
<field name="company_currency"/>
</t>
</td>
- <td valign="top" width="22"><img t-att-src="kanban_gravatar(record.user_email.value, 22)" class="oe_kanban_gravatar" t-att-title="record.user_id.value"/></td>
+ <td valign="top" width="22">
+ <img t-att-src="kanban_image('res.users', 'avatar', record.user_id.raw_value[0])" t-att-title="record.user_id.value"
+ width="22" height="22" class="oe_kanban_gravatar"/>
+ </td>
</tr>
</table>
=== added directory 'crm/doc'
=== added file 'crm/doc/crm_kanban_avatar.rst'
--- crm/doc/crm_kanban_avatar.rst 1970-01-01 00:00:00 +0000
+++ crm/doc/crm_kanban_avatar.rst 2012-03-23 10:36:21 +0000
@@ -0,0 +1,4 @@
+CRM kanban avatar specs
+=======================
+
+Kanban view of opportunities has been updated to use the newly-introduced avatar_mini field of res.users. The avatar is placed in the right-side of the containing kanban box.
=== added file 'crm/doc/index.rst'
--- crm/doc/index.rst 1970-01-01 00:00:00 +0000
+++ crm/doc/index.rst 2012-03-23 10:36:21 +0000
@@ -0,0 +1,6 @@
+:orphan:
+
+CRM module documentation
+========================
+
+.. include:: index.rst.inc
=== added file 'crm/doc/index.rst.inc'
--- crm/doc/index.rst.inc 1970-01-01 00:00:00 +0000
+++ crm/doc/index.rst.inc 2012-03-23 10:36:21 +0000
@@ -0,0 +1,8 @@
+
+CRM Module
+''''''''''
+
+.. toctree::
+ :maxdepth: 1
+
+ crm_kanban_avatar
=== added directory 'hr/doc'
=== added file 'hr/doc/hr_employee_img.rst'
--- hr/doc/hr_employee_img.rst 1970-01-01 00:00:00 +0000
+++ hr/doc/hr_employee_img.rst 2012-03-23 10:36:21 +0000
@@ -0,0 +1,8 @@
+HR photo specs
+==============
+
+This revision modifies the photo for HR employees. Two fields now exist in the hr.employee model:
+ - photo_stored, a binary field holding the image. It is base-64 encoded, and PIL-supported.
+ - photo, a functional binary field holding an automatically resized version of the photo. Dimensions of the resized photo are 180x150. This field is used as an inteface to get and set the employee photo. When changing this field in a view, the new image is automatically resized, and stored in the photo_stored field. Note that the value is stored on another field, because otherwise it would imply to write on the function field, which currently using OpenERP 6.1 can lead to issues.
+
+Employee photo should be used only when dealing with employees, using the photo field. When dealing with users, use the res.users avatar field instead.
=== added file 'hr/doc/index.rst'
--- hr/doc/index.rst 1970-01-01 00:00:00 +0000
+++ hr/doc/index.rst 2012-03-23 10:36:21 +0000
@@ -0,0 +1,6 @@
+:orphan:
+
+HR module documentation
+=======================
+
+.. include:: index.rst.inc
=== added file 'hr/doc/index.rst.inc'
--- hr/doc/index.rst.inc 1970-01-01 00:00:00 +0000
+++ hr/doc/index.rst.inc 2012-03-23 10:36:21 +0000
@@ -0,0 +1,8 @@
+
+HR Module
+'''''''''
+
+.. toctree::
+ :maxdepth: 1
+
+ hr_employee_img
=== modified file 'hr/hr.py'
--- hr/hr.py 2012-01-31 13:36:57 +0000
+++ hr/hr.py 2012-03-23 10:36:21 +0000
@@ -23,6 +23,9 @@
import logging
import addons
+import io, StringIO
+from PIL import Image
+
class hr_employee_category(osv.osv):
def name_get(self, cr, uid, ids, context=None):
@@ -145,6 +148,28 @@
_name = "hr.employee"
_description = "Employee"
_inherits = {'resource.resource': "resource_id"}
+
+ def onchange_photo(self, cr, uid, ids, value, context=None):
+ return {'value': {'photo_stored': self._photo_resize(cr, uid, value, 540, 450, context=context), 'photo': self._photo_resize(cr, uid, value, context=context) } }
+
+ def _set_photo(self, cr, uid, id, name, value, args, context=None):
+ return self.write(cr, uid, [id], {'photo_stored': self._photo_resize(cr, uid, value, 540, 450, context=context)}, context=context)
+
+ def _photo_resize(self, cr, uid, photo, heigth=180, width=150, context=None):
+ image_stream = io.BytesIO(photo.decode('base64'))
+ img = Image.open(image_stream)
+ img.thumbnail((heigth, width), Image.ANTIALIAS)
+ img_stream = StringIO.StringIO()
+ img.save(img_stream, "JPEG")
+ return img_stream.getvalue().encode('base64')
+
+ def _get_photo(self, cr, uid, ids, name, args, context=None):
+ result = dict.fromkeys(ids, False)
+ for hr_empl in self.browse(cr, uid, ids, context=context):
+ if hr_empl.photo_stored:
+ result[hr_empl.id] = self._photo_resize(cr, uid, hr_empl.photo_stored, context=context)
+ return result
+
_columns = {
'country_id': fields.many2one('res.country', 'Nationality'),
'birthday': fields.date("Date of Birth"),
@@ -170,7 +195,11 @@
'resource_id': fields.many2one('resource.resource', 'Resource', ondelete='cascade', required=True),
'coach_id': fields.many2one('hr.employee', 'Coach'),
'job_id': fields.many2one('hr.job', 'Job'),
- 'photo': fields.binary('Photo'),
+ 'photo_stored': fields.binary('Stored photo', help="This field holds the photo of the employee. The photo field is used as an interface to access this field. The image is base64 encoded, and PIL-supported. Stored photo are resized to 540x450 px."),
+ 'photo': fields.function(_get_photo, fnct_inv=_set_photo, string='Employee photo', type="binary",
+ store = {
+ 'hr.employee': (lambda self, cr, uid, ids, c={}: ids, ['photo_stored'], 10),
+ }, help="Image used as photo for the employee. It is automatically resized as a 180x150 px image. A larger photo is stored inside the photo_stored field."),
'passport_id':fields.char('Passport No', size=64),
'color': fields.integer('Color Index'),
'city': fields.related('address_id', 'city', type='char', string='City'),
@@ -217,10 +246,11 @@
def _get_photo(self, cr, uid, context=None):
photo_path = addons.get_module_resource('hr','images','photo.png')
- return open(photo_path, 'rb').read().encode('base64')
+ return self._photo_resize(cr, uid, open(photo_path, 'rb').read().encode('base64'), context=context)
_defaults = {
'active': 1,
+ 'photo_stored': _get_photo,
'photo': _get_photo,
'marital': 'single',
'color': 0,
=== modified file 'hr/hr_view.xml'
--- hr/hr_view.xml 2012-03-06 06:34:18 +0000
+++ hr/hr_view.xml 2012-03-23 10:36:21 +0000
@@ -34,7 +34,7 @@
<field name="parent_id" />
</group>
<group colspan="2" col="1">
- <field name="photo" widget='image' nolabel="1"/>
+ <field name="photo" widget='image' nolabel="1" on_change="onchange_photo(photo)"/>
</group>
</group>
<notebook colspan="6">
@@ -131,7 +131,6 @@
<field name="model">hr.employee</field>
<field name="type">kanban</field>
<field name="arch" type="xml">
-
<kanban>
<templates>
<t t-name="kanban-box">
=== added directory 'project/doc'
=== added file 'project/doc/index.rst'
--- project/doc/index.rst 1970-01-01 00:00:00 +0000
+++ project/doc/index.rst 2012-03-23 10:36:21 +0000
@@ -0,0 +1,6 @@
+:orphan:
+
+Project module documentation
+============================
+
+.. include:: index.rst.inc
=== added file 'project/doc/index.rst.inc'
--- project/doc/index.rst.inc 1970-01-01 00:00:00 +0000
+++ project/doc/index.rst.inc 2012-03-23 10:36:21 +0000
@@ -0,0 +1,8 @@
+
+Project Module
+''''''''''''''
+
+.. toctree::
+ :maxdepth: 1
+
+ task_kanban_avatar
=== added file 'project/doc/task_kanban_avatar.rst'
--- project/doc/task_kanban_avatar.rst 1970-01-01 00:00:00 +0000
+++ project/doc/task_kanban_avatar.rst 2012-03-23 10:36:21 +0000
@@ -0,0 +1,4 @@
+Task kanban avatar specs
+========================
+
+Kanban view of tasks has been updated to use the newly-introduced avatar_mini field of res.users. The avatar is placed in the right-side of the containing kanban box.
=== modified file 'project/project_view.xml'
--- project/project_view.xml 2012-03-22 17:23:05 +0000
+++ project/project_view.xml 2012-03-23 10:36:21 +0000
@@ -354,7 +354,8 @@
<field name="name"/>
</td>
<td valign="top" width="22">
- <img t-att-src="kanban_gravatar(record.user_email.value, 22)" class="oe_kanban_gravatar" t-att-title="record.user_id.value"/>
+ <img t-att-src="kanban_image('res.users', 'avatar', record.user_id.raw_value[0])" t-att-title="record.user_id.value"
+ width="22" height="22" class="oe_kanban_gravatar"/>
</td>
</tr>
</table>
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp