[MERGE] Merged with user_img branch

bzr revid: tde@openerp.com-20120315103847-teqa5ciaa45y5h3u
This commit is contained in:
Thibault Delavallée
2012-03-15 11:38:47 +01:00
15 changed files with 123 additions and 83 deletions
+4 -1
View File
@@ -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_mini', record.user_id.raw_value[0])" t-att-title="record.user_id.value"
width="22" height="22" class="oe_kanban_gravatar"/>
</td>
</tr>
</table>
+4
View File
@@ -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.
+6
View File
@@ -0,0 +1,6 @@
:orphan:
CRM module documentation
========================
.. include:: index.rst.inc
+8
View File
@@ -0,0 +1,8 @@
CRM Module
''''''''''
.. toctree::
:maxdepth: 1
crm_kanban_avatar
+8
View File
@@ -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, a binary field holding the image
- photo_mini, a binary field holding an automatically resized version of the avatar. Dimensions of the resized avatar are 180x150.
Employee photo should be used only when dealing with employees, using the photo_mini field. When dealing with users, use the res.users avatar_mini field instead.
+6
View File
@@ -0,0 +1,6 @@
:orphan:
HR module documentation
=======================
.. include:: index.rst.inc
+8
View File
@@ -0,0 +1,8 @@
HR Module
'''''''''
.. toctree::
:maxdepth: 1
hr_employee_img
+21 -17
View File
@@ -149,24 +149,28 @@ class hr_employee(osv.osv):
_description = "Employee"
_inherits = {'resource.resource': "resource_id"}
def onchange_photo_mini(self, cr, uid, ids, value, context=None):
return {'value': {'photo': value, 'photo_mini': self._photo_resize(cr, uid, value) } }
def _set_photo_mini(self, cr, uid, id, name, value, args, context=None):
return self.write(cr, uid, [id], {'photo': value}, context=context)
def _photo_resize(self, cr, uid, photo, context=None):
image_stream = io.BytesIO(photo.decode('base64'))
img = Image.open(image_stream)
img.thumbnail((180, 150), Image.ANTIALIAS)
img_stream = StringIO.StringIO()
img.save(img_stream, "JPEG")
return img_stream.getvalue().encode('base64')
def _get_photo_mini(self, cr, uid, ids, name, args, context=None):
result = {}
for obj in self.browse(cr, uid, ids, context=context):
if not obj.photo:
result[obj.id] = False
continue
image_stream = io.BytesIO(obj.photo.decode('base64'))
img = Image.open(image_stream)
img.thumbnail((180, 150), Image.ANTIALIAS)
img_stream = StringIO.StringIO()
img.save(img_stream, "JPEG")
result[obj.id] = img_stream.getvalue().encode('base64')
for hr_empl in self.browse(cr, uid, ids, context=context):
if not hr_empl.photo:
result[hr_empl.id] = False
else:
result[hr_empl.id] = self._photo_resize(cr, uid, hr_empl.photo, context=context)
return result
def _set_photo_mini(self, cr, uid, id, name, value, args, context=None):
self.write(cr, uid, [id], {'photo': value}, context=context)
return True
_columns = {
'country_id': fields.many2one('res.country', 'Nationality'),
@@ -244,11 +248,11 @@ class hr_employee(osv.osv):
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'))
_defaults = {
'active': 1,
'photo': _get_photo,
'photo_mini': _get_photo,
'marital': 'single',
'color': 0,
}
+2 -2
View File
@@ -33,7 +33,7 @@
<field name="parent_id" />
</group>
<group colspan="2" col="1">
<field name="photo_mini" widget='image' nolabel="1"/>
<field name="photo_mini" widget='image' nolabel="1" on_change="onchange_photo_mini(photo_mini)"/>
</group>
</group>
<notebook colspan="6">
@@ -135,7 +135,7 @@
<t t-name="kanban-box">
<div class="oe_employee_vignette">
<div class="oe_employee_image">
<a type="edit"><img t-att-src="kanban_image('hr.employee', 'photo', record.id.value)" class="oe_employee_picture"/></a>
<a type="edit"><img t-att-src="kanban_image('hr.employee', 'photo_mini', record.id.value)" class="oe_employee_picture"/></a>
</div>
<div class="oe_employee_details">
<h4><a type="edit"><field name="name"/> (<field name="login"/>)</a></h4>
-3
View File
@@ -67,9 +67,6 @@ Dashboard for project members that includes:
'test/project_process.yml',
'test/task_process.yml',
],
'css': [
'static/src/css/project_task.css',
],
'installable': True,
'auto_install': False,
'application': True,
+6
View File
@@ -0,0 +1,6 @@
:orphan:
Project module documentation
============================
.. include:: index.rst.inc
+8
View File
@@ -0,0 +1,8 @@
Project Module
''''''''''''''
.. toctree::
:maxdepth: 1
task_kanban_avatar
@@ -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.
+38 -39
View File
@@ -344,46 +344,45 @@
<t t-if="record.kanban_state.raw_value === 'done'" t-set="border">oe_kanban_color_green</t>
<div t-attf-class="#{kanban_color(record.color.raw_value)} #{border || ''}">
<div class="oe_kanban_box oe_kanban_color_border">
<div class="oe_proj_task_avatar_box">
<img t-att-src="kanban_image('res.users', 'avatar_mini', record.user_id.raw_value[0])" class="oe_kanban_avatar" t-att-title="record.user_id.value"/>
</div>
<div class="oe_proj_task_content_box">
<table class="oe_kanban_table oe_kanban_box_header oe_kanban_color_bgdark oe_kanban_color_border oe_kanban_draghandle">
<tr>
<td align="left" valign="middle" width="16">
<a t-if="record.priority.raw_value == 1" icon="star-on" type="object" name="set_normal_priority"/>
<a t-if="record.priority.raw_value != 1" icon="star-off" type="object" name="set_high_priority" style="opacity:0.6; filter:alpha(opacity=60);"/>
</td>
<td align="left" valign="middle" class="oe_kanban_title" tooltip="task_details">
<field name="name"/>
</td>
</tr>
</table>
<div class="oe_kanban_box_content oe_kanban_color_bglight oe_kanban_box_show_onclick_trigger">
<div class="oe_kanban_description">
<t t-esc="kanban_text_ellipsis(record.description.value, 160)"/>
<i t-if="record.date_deadline.raw_value">
<t t-if="record.description.raw_value">, </t>
<field name="date_deadline"/>
</i>
<span class="oe_kanban_project_times" style="white-space: nowrap; padding-left: 5px;">
<t t-set="hours" t-value="record.remaining_hours.raw_value"/>
<t t-set="times" t-value="[
[1, (hours gte 1 and hours lt 2)]
,[2, (hours gte 2 and hours lt 5)]
,[5, (hours gte 5 and hours lt 10)]
,[10, (hours gte 10)]
]"/>
<t t-foreach="times" t-as="time"
><a t-if="!time[1]" t-attf-data-name="set_remaining_time_#{time[0]}"
type="object" class="oe_kanban_button"><t t-esc="time[0]"/></a
><b t-if="time[1]" class="oe_kanban_button oe_kanban_button_active"><t t-esc="Math.round(hours)"/></b
></t>
<a name="do_open" states="draft" string="Validate planned time and open task" type="object" class="oe_kanban_button oe_kanban_button_active">!</a>
</span>
</div>
<div class="oe_kanban_clear"/>
<table class="oe_kanban_table oe_kanban_box_header oe_kanban_color_bgdark oe_kanban_color_border oe_kanban_draghandle">
<tr>
<td align="left" valign="middle" width="16">
<a t-if="record.priority.raw_value == 1" icon="star-on" type="object" name="set_normal_priority"/>
<a t-if="record.priority.raw_value != 1" icon="star-off" type="object" name="set_high_priority" style="opacity:0.6; filter:alpha(opacity=60);"/>
</td>
<td align="left" valign="middle" class="oe_kanban_title" tooltip="task_details">
<field name="name"/>
</td>
<td valign="top" width="22">
<img t-att-src="kanban_image('res.users', 'avatar_mini', record.user_id.raw_value[0])" t-att-title="record.user_id.value"
width="22" height="22" class="oe_kanban_gravatar"/>
</td>
</tr>
</table>
<div class="oe_kanban_box_content oe_kanban_color_bglight oe_kanban_box_show_onclick_trigger">
<div class="oe_kanban_description">
<t t-esc="kanban_text_ellipsis(record.description.value, 160)"/>
<i t-if="record.date_deadline.raw_value">
<t t-if="record.description.raw_value">, </t>
<field name="date_deadline"/>
</i>
<span class="oe_kanban_project_times" style="white-space: nowrap; padding-left: 5px;">
<t t-set="hours" t-value="record.remaining_hours.raw_value"/>
<t t-set="times" t-value="[
[1, (hours gte 1 and hours lt 2)]
,[2, (hours gte 2 and hours lt 5)]
,[5, (hours gte 5 and hours lt 10)]
,[10, (hours gte 10)]
]"/>
<t t-foreach="times" t-as="time"
><a t-if="!time[1]" t-attf-data-name="set_remaining_time_#{time[0]}"
type="object" class="oe_kanban_button"><t t-esc="time[0]"/></a
><b t-if="time[1]" class="oe_kanban_button oe_kanban_button_active"><t t-esc="Math.round(hours)"/></b
></t>
<a name="do_open" states="draft" string="Validate planned time and open task" type="object" class="oe_kanban_button oe_kanban_button_active">!</a>
</span>
</div>
<div class="oe_kanban_clear"/>
</div>
<div class="oe_kanban_buttons_set oe_kanban_color_border oe_kanban_color_bglight oe_kanban_box_show_onclick">
<div class="oe_kanban_left">
@@ -1,21 +0,0 @@
.openerp .oe_proj_task_content_box {
margin-right: 41px;
}
.openerp .oe_proj_task_avatar_box {
float: right;
width: 40px;
}
.openerp .oe_kanban_avatar {
display: block;
width: 40px;
height: auto;
clip: rect(5px, 40px, 45px, 0px);
}
.openerp .oe_kanban_avatar_wide {
height: 40px;
width: auto;
clip: rect(0px, 45px, 40px, 05px);
}