[REF] remove changes in for social module

bzr revid: mat@openerp.com-20130321152355-k9yt5rz2vbjjqefn
This commit is contained in:
Martin Trigaux 2013-03-21 16:23:55 +01:00
parent c29e0693a0
commit 07145d458a
5 changed files with 8 additions and 141 deletions

View File

@ -58,7 +58,7 @@
<field name="view_mode">tree,calendar</field>
<field name="view_id" ref="crm_case_inbound_phone_tree_view"/>
<field name="domain">[]</field>
<field name="context" eval="'{\'default_state\':\'done\'}'"/>
<field name="context">{}</field>
<field name="search_view_id" ref="crm.view_crm_case_phonecalls_filter"/>
<field name="help" type="html">
<p class="oe_view_nocontent_create">

View File

@ -23,6 +23,5 @@ import hr_department
import hr
import res_config
import res_users
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -218,26 +218,6 @@ class hr_employee(osv.osv):
_order='name_related'
def create(self, cr, uid, data, context=None):
# verify do not have two employee with the same email
if 'work_email' in data:
user_ids = self.pool.get('res.users').search(cr, uid, [('email', '=', data['work_email'])], context=context)
if len(user_ids) > 0:
if 'user_id' not in data:
raise osv.except_osv(_('Warning!'), _('You are trying to create an employee with an email already linked to an user. Please linked the employee to it or change the email.'))
elif data['user_id'] not in user_ids:
raise osv.except_osv(_('Warning!'), _('You are trying to create an employee with an email different than the one of the linked user.'))
# else user and email match
else:
# employee has an email but not the user
# TOCHECK update user ?
pass
elif 'user_id' in data:
user = self.pool.get('res.users').browse(cr, uid, data['user_id'], context=context)
if user.email:
# employee has no email but the user does
# TOCHECK raise error ?
pass
employee_id = super(hr_employee, self).create(cr, uid, data, context=context)
try:
(model, mail_group_id) = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'mail', 'group_all_employees')
@ -246,8 +226,7 @@ class hr_employee(osv.osv):
body='Welcome to %s! Please help them take the first steps with OpenERP!' % (employee.name),
subtype='mail.mt_comment', context=context)
except:
pass # group deleted: do not push a message
pass # group deleted: do not push a message
return employee_id
def unlink(self, cr, uid, ids, context=None):
@ -287,46 +266,6 @@ 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,10 +27,6 @@
</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 -->
@ -40,11 +36,14 @@
<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>
<group string="Position">
<field name="department_id" on_change="onchange_department_id(department_id)"/>
<field name="job_id" options='{"no_open": True}' domain="[('state','!=','old')]" context="{'form_view_ref': 'hr.view_hr_job_employee_form'}"/>
<field name="parent_id"/>
<field name="coach_id"/>
</group>
@ -85,7 +84,6 @@
</group>
</page>
</notebook>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers"/>
@ -130,16 +128,14 @@
</search>
</field>
</record>
<!-- HR Kanban View -->
<!-- HR Kanban View -->
<record model="ir.ui.view" id="hr_kanban_view_employees">
<field name="name">HR - Employess Kanban</field>
<field name="model">hr.employee</field>
<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">
@ -158,15 +154,10 @@
</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

@ -1,62 +0,0 @@
from openerp.osv import osv
class res_users_employee_group(osv.Model):
""" Update of res.users class
- if adding groups to an user, check if base.group_user is in it
(member of 'Employee'), create an employee form linked to it.
"""
_name = 'res.users'
_inherit = ['res.users']
def write(self, cr, uid, ids, vals, context=None):
write_res = super(res_users_employee_group, self).write(cr, uid, ids, vals, context=context)
if vals.get('groups_id'):
# form: {'group_ids': [(3, 10), (3, 3), (4, 10), (4, 3)]} or {'group_ids': [(6, 0, [ids]}
user_group_ids = [command[1] for command in vals['groups_id'] if command[0] == 4]
user_group_ids += [id for command in vals['groups_id'] if command[0] == 6 for id in command[2]]
(model, group_id) = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'base', 'group_user')
emp_obj = self.pool.get('hr.employee')
if group_id in user_group_ids:
# base.group_user in it, checking users
for user in self.browse(cr, uid, ids, context=context):
if len(emp_obj.search(cr, uid, [('user_id', '=', user.id)], context=context)) == 0:
# no employee already linked to this user, create it
emp_obj.create(cr, uid, {
'user_id': user.id,
'name': user.name,
'image': user.image,
}, context=context)
return write_res
class res_groups_employee_group(osv.Model):
""" Update of res.groups class
- if adding users to a group, check if base.group_user and if the case,
create a employee profile
"""
_name = 'res.groups'
_inherit = 'res.groups'
def write(self, cr, uid, ids, vals, context=None):
write_res = super(res_groups_employee_group, self).write(cr, uid, ids, vals, context=context)
(model, group_id) = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'base', 'group_user')
# check adding users to base.group_user
if vals.get('users') and group_id in ids:
# form: {'group_ids': [(3, 10), (3, 3), (4, 10), (4, 3)]} or {'group_ids': [(6, 0, [ids]}
user_ids = [command[1] for command in vals['users'] if command[0] == 4]
user_ids += [id for command in vals['users'] if command[0] == 6 for id in command[2]]
emp_obj = self.pool.get('hr.employee')
for user_id in user_ids:
if len(emp_obj.search(cr, uid, [('user_id', '=', user_id)], context=context)) == 0:
# no employee already linked to this user, create it
user = self.pool.get('res.users').browse(cr, uid, user_id, context=context)
emp_obj.create(cr, uid, {
'user_id': user.id,
'name': user.name,
'image': user.image,
}, context=context)
return write_res