[ADD] additions from trunk-hr-goal-mat

bzr revid: mat@openerp.com-20130320111520-fmz14if4k400s9s4
This commit is contained in:
Martin Trigaux 2013-03-20 12:15:20 +01:00
parent c0c2bcd62e
commit 307818ea0b
6 changed files with 85 additions and 5 deletions

View File

@ -59,6 +59,7 @@ You can manage:
'hr_installer.xml',
'hr_data.xml',
'res_config_view.xml',
'mail_hr_view.xml',
],
'demo': ['hr_demo.xml'],
'test': [

View File

@ -23,6 +23,8 @@ from openerp import addons
import logging
from openerp.osv import fields, osv
from openerp import tools
from openerp.tools.translate import _
_logger = logging.getLogger(__name__)
class hr_employee_category(osv.osv):
@ -264,6 +266,45 @@ class hr_employee(osv.osv):
image_path = addons.get_module_resource('hr', 'static/src/img', 'default_image.png')
return tools.image_resize_image_big(open(image_path, 'rb').read().encode('base64'))
def action_follow(self, cr, uid, ids, context=None):
""" Wrapper because message_subscribe_users take a user_ids=None
that receive the context without the wrapper. """
return self.message_subscribe_users(cr, uid, ids, context=context)
def action_unfollow(self, cr, uid, ids, context=None):
""" Wrapper because message_unsubscribe_users take a user_ids=None
that receive the context without the wrapper. """
return self.message_unsubscribe_users(cr, uid, ids, context=context)
def message_post(self, cr, uid, thread_id, context=None, **kwargs):
"""Overwrite the message_post method when using the send to my
followers screen
When a message is sent to a hr.employee using the action
action_mail_inbox_feeds, the context is extended with res_users_id
containing the user id of the user linked to the employee and
default_res_id contains 0 (to avoid misused of the function called from
the inbox page).
In these conditions, the thread_id used to send the message is the id
of the employee instead of the res_users (or partner_id).
If several employee are linked to the same user_id, the message is
duplicated and sent to every user.
:return: the result of message_post from mail_thread, last call if
several messages are sent.
"""
if 'res_users_id' in context: # and context['default_res_id'] == 0:
employee_ids = self.search(cr, uid, [('user_id', '=', context['res_users_id'])], context=context)
if len(employee_ids) > 0:
for employee_id in employee_ids:
res = super(hr_employee, self).message_post(cr, uid, employee_id, context=context, **kwargs)
return res
else:
raise osv.except_osv(_('Warning!'), _('Your user is not linked to an employee form, which is required to send messages to your followers.'))
# if no overwrite, send message as usual
return super(hr_employee, self).message_post(cr, uid, thread_id, context=context, **kwargs)
_defaults = {
'active': 1,
'image': _get_default_image,

View File

@ -27,6 +27,10 @@
</h1>
<label for="category_ids" class="oe_edit_only" groups="base.group_hr_user"/>
<field name="category_ids" widget="many2many_tags" placeholder="e.g. Part Time" groups="base.group_hr_user"/>
<label for="work_email" class="oe_edit_only"/>
<field name="work_email" widget="email"/>
<label for="work_phone" class="oe_edit_only"/>
<field name="work_phone"/>
</div>
<div class="oe_right oe_button_box" name="button_box">
<!-- Put here related buttons -->
@ -36,8 +40,6 @@
<group>
<group string="Contact Information">
<field name="address_id" on_change="onchange_address_id(address_id)" context="{'show_address': 1}" options='{"always_reload": True, "highlight_first_line": True}'/>
<field name="work_email" widget="email"/>
<field name="work_phone"/>
<field name="mobile_phone"/>
<field name="work_location"/>
</group>
@ -136,6 +138,7 @@
<field name="arch" type="xml">
<kanban>
<field name="last_login"/>
<field name="message_is_follower"/>
<templates>
<t t-name="kanban-box">
<div class="oe_employee_vignette">
@ -154,10 +157,15 @@
</li>
<li t-if="record.job_id.raw_value"><field name="job_id"/></li>
<li t-if="record.work_location.raw_value"><field name="work_location"/></li>
<li t-if="record.work_phone.raw_value">Tel: <field name="work_phone"/></li>
<li t-if="record.mobile_phone.raw_value">Mobile: <field name="mobile_phone"/></li>
<li t-if="record.work_email.raw_value"><a t-attf-href="mailto:#{record.work_email.value}"><field name="work_email"/></a></li>
</ul>
<div class="oe_followers">
<button t-if="record.message_is_follower.raw_value" name="action_unfollow" type="object" class="oe_follower oe_following">
<span class="oe_unfollow">Unfollow</span>
<span class="oe_following">Following</span>
</button>
<button t-if="! record.message_is_follower.raw_value" name="action_follow" type="object" class="oe_follower oe_notfollow">Follow</button>
</div>
</div>
</div>
<script>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="mail.action_mail_inbox_feeds" model="ir.actions.client">
<field name="context">{
'default_model': 'hr.employee',
'default_res_id': uid,
'res_users_id': uid,
}</field>
<field name="params" eval="&quot;{
'domain': [
('to_read', '=', True),
('starred', '=', False),
],
'view_mailbox': True,
'view_inbox': True,
'read_action': 'read',
'show_compose_message': True
}&quot;"/>
</record>
</data>
</openerp>

View File

@ -68,3 +68,8 @@
margin: 2px 0;
padding: 0;
}
.openerp .oe_employee_vignette .oe_followers {
width: auto;
float: none;
}

View File

@ -16,7 +16,8 @@
],
'view_mailbox': True,
'view_inbox': True,
'read_action': 'read'
'read_action': 'read',
'show_compose_message': False
}&quot;"/>
<field name="help" type="html">
<p>