[REM] mail, hr: removed suggested groups / suggested employees feature.

Removed fields and code related to the display of groups and employee
suggestions. This impacts notably the model of res.users in mail and
hr.
This commit is contained in:
Thibault Delavallée
2015-07-09 10:09:10 +02:00
parent 8269d3bd3b
commit 1c38e61c35
19 changed files with 3 additions and 459 deletions
@@ -119,12 +119,4 @@ var Sidebar = Widget.extend({
}
});
mail.TimelineView.include({
start: function() {
this._super();
var sidebar = new Sidebar(this);
sidebar.appendTo($('.o_timeline__inbox_aside'));
},
});
});
+1 -2
View File
@@ -46,7 +46,6 @@ You can manage:
'hr_tip_data.xml',
'res_config_view.xml',
'mail_hr_view.xml',
'res_users_view.xml',
'views/hr.xml',
'hr_dashboard.xml',
],
@@ -59,5 +58,5 @@ You can manage:
'installable': True,
'application': True,
'auto_install': False,
'qweb': ['static/src/xml/suggestions.xml'],
'qweb': [],
}
-9
View File
@@ -266,15 +266,6 @@ class hr_employee(osv.osv):
that receive the context without the wrapper. """
return self.message_unsubscribe_users(cr, uid, ids, context=context)
def get_suggested_thread(self, cr, uid, removed_suggested_threads=None, context=None):
"""Show the suggestion of employees if display_employees_suggestions if the
user perference allows it. """
user = self.pool.get('res.users').browse(cr, uid, uid, context)
if not user.display_employees_suggestions:
return []
else:
return super(hr_employee, self).get_suggested_thread(cr, uid, removed_suggested_threads, context)
def _message_get_auto_subscribe_fields(self, cr, uid, updated_fields, auto_follow_fields=None, context=None):
""" Overwrite of the original method to always follow user_id field,
even when not track_visibility so that a user will follow it's employee
-26
View File
@@ -13,34 +13,8 @@ class res_users(osv.Model):
_columns = {
'employee_ids': fields.one2many('hr.employee', 'user_id', 'Related employees'),
'display_employees_suggestions': fields.boolean("Display Employees Suggestions"),
}
_defaults = {
'display_employees_suggestions': True,
}
def __init__(self, pool, cr):
""" Override of __init__ to add access rights on
display_employees_suggestions fields. Access rights are disabled by
default, but allowed on some specific fields defined in
self.SELF_{READ/WRITE}ABLE_FIELDS.
"""
init_res = super(res_users, self).__init__(pool, cr)
# duplicate list to avoid modifying the original reference
self.SELF_WRITEABLE_FIELDS = list(self.SELF_WRITEABLE_FIELDS)
self.SELF_WRITEABLE_FIELDS.append('display_employees_suggestions')
# duplicate list to avoid modifying the original reference
self.SELF_READABLE_FIELDS = list(self.SELF_READABLE_FIELDS)
self.SELF_READABLE_FIELDS.append('display_employees_suggestions')
return init_res
def stop_showing_employees_suggestions(self, cr, uid, user_id, context=None):
"""Update display_employees_suggestions value to False"""
if context is None:
context = {}
self.write(cr, uid, user_id, {"display_employees_suggestions": False}, context)
def _message_post_get_eid(self, cr, uid, thread_id, context=None):
assert thread_id, "res.users does not support posting global messages"
if context and 'thread_model' in context:
-20
View File
@@ -1,20 +0,0 @@
<?xml version="1.0"?>
<openerp>
<data>
<!-- Update user form !-->
<record id="view_users_form_mail" model="ir.ui.view">
<field name="name">res.users.form.hr</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="mail.view_users_form_mail"/>
<field name="arch" type="xml">
<data>
<field name="display_groups_suggestions" position="after">
<field name="display_employees_suggestions"/>
</field>
</data>
</field>
</record>
</data>
</openerp>
-83
View File
@@ -1,83 +0,0 @@
odoo.define('hr.suggestions', function (require) {
"use strict";
var mail = require('mail.mail');
var core = require('web.core');
var data = require('web.data');
var Widget = require('web.Widget');
var QWeb = core.qweb;
var removed_suggested_employee = [];
var Employees = Widget.extend({
events: {
'click .oe_suggestion_remove.oe_suggestion_employee': 'stop_employee_suggestion',
'click .oe_suggestion_remove_item.oe_suggestion_employee': 'remove_employee_suggestion',
'click .oe_suggestion_follow': 'follow_employee',
},
init: function () {
this._super(this, arguments);
this.hr_employee = new data.DataSetSearch(this, 'hr.employee');
this.res_users = new data.DataSetSearch(this, 'res.users');
this.employees = [];
},
start: function () {
this._super.apply(this, arguments);
return this.fetch_suggested_employee();
},
fetch_suggested_employee: function () {
var self = this;
var employee = self.hr_employee.call('get_suggested_thread', {'removed_suggested_threads': removed_suggested_employee}).then(function (res) {
_(res).each(function (result) {
result['image']=self.session.url('/web/binary/image', {model: 'hr.employee', field: 'image_small', id: result.id});
});
self.employees = res;
});
return $.when(employee).done(this.proxy('display_suggested_employees'));
},
display_suggested_employees: function () {
var suggested_employees = this.$('.oe_sidebar_suggestion.oe_suggestion_employee');
if (suggested_employees) {
suggested_employees.remove();
}
if (this.employees.length === 0) {
return this.$el.empty();
}
return this.$el.empty().html(QWeb.render('hr.suggestions.employees', {'widget': this}));
},
follow_employee: function (event) {
var self = this;
var employee_id = parseInt($(event.currentTarget).attr('id'), 10);
return this.hr_employee.call('message_subscribe_users', [[employee_id], [this.session.uid], undefined]).then(function(res) {
self.fetch_suggested_employee();
});
},
remove_employee_suggestion: function (event) {
removed_suggested_employee.push($(event.currentTarget).attr('id'));
return this.fetch_suggested_employee();
},
stop_employee_suggestion: function (event) {
var self = this;
return this.res_users.call('stop_showing_employees_suggestions', [this.session.uid]).then(function(res) {
self.$(".oe_sidebar_suggestion.oe_suggestion_employee").hide();
});
}
});
mail.Sidebar.include({
start: function () {
this._super.apply(this, arguments);
var sug_employees = new Employees(this);
return sug_employees.appendTo(this.$('.oe_suggestions_employees'));
},
});
});
-36
View File
@@ -1,36 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<template>
<!-- Employees placeholder in sidebar -->
<t t-extend="mail.wall.sidebar">
<t t-jquery=".oe_mail_wall_sidebar" t-operation="append">
<div class="oe_suggestions_employees"></div>
</t>
</t>
<!-- Suggested employees -->
<div t-name="hr.suggestions.employees" class="oe_sidebar_suggestion oe_suggestion_employee">
<div class="oe_suggest_title">
<i class="oe_suggestion_remove oe_suggestion_employee fa fa-times"/>
<h2>Suggested Employees</h2>
</div>
<div class="oe_suggest_items">
<t t-foreach="widget.employees" t-as="result">
<div class="oe_suggested_item">
<div class="oe_suggested_item_image">
<a t-attf-href="#model=hr.employee&amp;id=#{result.id}">
<img t-att-src="result.image" t-att-alt="result.name"/>
</a>
</div>
<div class="oe_suggested_item_content">
<a class="oe_suggestion_item_name" t-attf-href="#model=hr.employee&amp;id=#{result.id}"><t t-esc="result.name"/></a>
<i class="oe_suggestion_remove_item oe_suggestion_employee fa fa-times" t-att-id="result.id"/>
<br/>
<button class="oe_suggestion_follow" t-att-id="result.id">Follow</button>
</div>
</div>
</t>
</div>
</div>
</template>
-1
View File
@@ -5,7 +5,6 @@
<xpath expr="." position="inside">
<link rel="stylesheet" href="/hr/static/src/css/hr.css"/>
<link rel="stylesheet" href="/hr/static/src/less/hr_dashboard.less"/>
<script type="text/javascript" src="/hr/static/src/js/suggestions.js"></script>
</xpath>
</template>
</data>
-1
View File
@@ -61,6 +61,5 @@ Main Features
'static/src/xml/mail.xml',
'static/src/xml/mail_followers.xml',
'static/src/xml/announcement.xml',
'static/src/xml/suggestions.xml',
],
}
-8
View File
@@ -164,14 +164,6 @@ class MailGroup(models.Model):
that receive the context without the wrapper. """
return self.message_unsubscribe_users()
@api.model
def get_suggested_thread(self, removed_suggested_threads=None):
"""Show the suggestion of groups if display_groups_suggestions if the
user perference allows it."""
if not self.env.user.display_groups_suggestions:
return []
return super(MailGroup, self).get_suggested_thread(removed_suggested_threads)
@api.multi
def message_get_email_values(self, notif_mail=None):
self.ensure_one()
-23
View File
@@ -1840,29 +1840,6 @@ class MailThread(models.AbstractModel):
self.env['mail.notification'].invalidate_cache(['is_read'])
return True
@api.model
def get_suggested_thread(self, removed_suggested_threads=None):
"""Return a list of suggested threads, sorted by the numbers of followers"""
# TDE HACK: originally by MAT from portal/mail_mail.py but not working until the inheritance graph bug is not solved in trunk
# TDE FIXME: relocate in portal when it won't be necessary to reload the hr.employee model in an additional bridge module
if 'is_portal' in self.pool['res.groups']._fields:
if any(group.is_portal for group in self.env.user.sudo().groups_id):
return []
threads = []
if removed_suggested_threads is None:
removed_suggested_threads = []
for thread in self.search([('id', 'not in', removed_suggested_threads), ('message_is_follower', '=', False)]):
data = {
'id': thread.id,
'popularity': len(thread.message_follower_ids),
'name': thread.name,
'image_small': thread.image_small
}
threads.append(data)
return sorted(threads, key=lambda x: (x['popularity'], x['id']), reverse=True)[:3]
@api.multi
def message_change_thread(self, new_thread):
"""
+2 -6
View File
@@ -18,7 +18,6 @@ class Users(models.Model):
alias_id = fields.Many2one('mail.alias', 'Alias', ondelete="restrict", required=True,
help="Email address internally associated with this user. Incoming "\
"emails will appear in the user's notifications.", copy=False, auto_join=True)
display_groups_suggestions = fields.Boolean("Display Groups Suggestions", default=True)
def __init__(self, pool, cr):
""" Override of __init__ to add access rights on notification_email_send
@@ -28,10 +27,10 @@ class Users(models.Model):
init_res = super(Users, self).__init__(pool, cr)
# duplicate list to avoid modifying the original reference
self.SELF_WRITEABLE_FIELDS = list(self.SELF_WRITEABLE_FIELDS)
self.SELF_WRITEABLE_FIELDS.extend(['notify_email', 'display_groups_suggestions'])
self.SELF_WRITEABLE_FIELDS.extend(['notify_email'])
# duplicate list to avoid modifying the original reference
self.SELF_READABLE_FIELDS = list(self.SELF_READABLE_FIELDS)
self.SELF_READABLE_FIELDS.extend(['notify_email', 'alias_domain', 'alias_name', 'display_groups_suggestions'])
self.SELF_READABLE_FIELDS.extend(['notify_email', 'alias_domain', 'alias_name'])
return init_res
def _auto_init(self, cr, context=None):
@@ -123,9 +122,6 @@ class Users(models.Model):
def message_get_suggested_recipients(self):
return dict((res_id, list()) for res_id in self._ids)
def stop_showing_groups_suggestions(self):
self.write({"display_groups_suggestions": False})
class res_users_mail_group(models.Model):
""" Update of res.users class
-87
View File
@@ -1018,90 +1018,3 @@
border-bottom: 1px solid #dddddd;
margin-bottom: 10px;
}
/* ----------------------- SIDEBAR ----------------------- */
.o_web_client .o_timeline .o_timeline_inbox_aside {
margin-left: 10px;
margin-top: 5px;
position: relative;
display: inline-block;
vertical-align: top;
width: 200px;
}
.o_web_client .o_timeline .o_timeline_inbox_aside .oe_sidebar_suggestion {
background-color: #f0eeee;
border: solid 1px #CACACA;
border-radius: 3px;
padding-top: 1px;
padding-bottom: 7px;
margin-bottom: 20px
}
.o_web_client .o_timeline .o_timeline_inbox_aside .oe_suggest_title span {
background-color: #f0eeee;
display: inline-block;
height: 25px;
vertical-align: middle;
font-size: 14px;
font-weight: bold;
margin-left: 10px;
margin-top: -20px;
padding-left: 5px;
padding-right: 5px;
}
.o_web_client .oe_sidebar_suggestion .oe_suggest_items .oe_suggested_item {
border-radius: 2px;
margin-left: 10px;
min-height: 67px;
white-space: nowrap;
}
.o_web_client .oe_sidebar_suggestion .oe_suggest_items .oe_suggested_item_image {
float: left;
padding-right: 10px;
}
.o_web_client .oe_sidebar_suggestion .oe_suggest_items .oe_suggested_item_image img {
border-radius: 2px;
border: solid 1px rgba(0,0,0,0.03);
}
.o_web_client .oe_sidebar_suggestion .oe_suggest_items .oe_suggested_item_content button {
margin-top: 10px;
}
.o_web_client .oe_sidebar_suggestion .oe_suggest_items .oe_suggested_item_content .oe_suggestion_item_name {
display: inline-block;
text-overflow: ellipsis;
overflow: hidden;
max-width: 110px;
}
.o_web_client .o_timeline .o_timeline_inbox_aside a {
color: #337ab7;
}
.o_web_client .oe_sidebar_suggestion .oe_suggest_title .oe_suggestion_remove {
line-height: 15px;
margin-top: -2px;
float: right;
visibility: hidden;
margin-right: 7px;
}
.o_web_client .oe_sidebar_suggestion .oe_suggest_items .oe_suggested_item_content .oe_suggestion_remove_item {
line-height: 21px;
margin-top: -2px;
float: right;
visibility: hidden;
margin-right: 16px;
}
.o_web_client .oe_sidebar_suggestion .oe_suggest_title:hover .oe_suggestion_remove,
.o_web_client .oe_sidebar_suggestion .oe_suggest_items:hover .oe_suggestion_remove_item {
visibility: visible;
}
-19
View File
@@ -129,12 +129,6 @@ var TimelineView = View.extend ({
this.has_been_loaded = $.Deferred();
},
start: function () {
var wall_sidebar = new Sidebar(this);
wall_sidebar.appendTo(this.$('.o_timeline_inbox_aside'));
return this._super.apply(this, arguments);
},
view_loading: function (fields_view_get) {
return this.load_timeline(fields_view_get);
},
@@ -1495,18 +1489,6 @@ var ComposeMessage = Attachment.extend ({
},
});
/**
* ------------------------------------------------------------
* Aside Widget
* ------------------------------------------------------------
*
* This widget handles the display of a sidebar in the inbox. Its main
* use is to display group and employees suggestion (if hr is installed).
*/
var Sidebar = Widget.extend({
template: 'TimelineSidebar',
});
/**
* ------------------------------------------------------------
* UserMenu
@@ -1553,7 +1535,6 @@ return {
TimelineView: TimelineView,
MailThread: MailThread,
TimelineRecordThread: TimelineRecordThread,
Sidebar: Sidebar,
};
});
-83
View File
@@ -1,83 +0,0 @@
odoo.define('mail.suggestion', function (require) {
var mail = require('mail.mail');
var core = require('web.core');
var data = require('web.data');
var real_session = require('web.session');
var Widget = require('web.Widget');
var QWeb = core.qweb;
var removed_suggested_group = [];
var Groups = Widget.extend({
events: {
'click .oe_suggestion_remove.oe_suggestion_group': 'stop_group_suggestion',
'click .oe_suggestion_remove_item.oe_suggestion_group': 'remove_group_suggestion',
'click .oe_suggestion_join': 'join_group',
},
init: function () {
this._super.apply(this, arguments);
this.mail_group = new data.DataSetSearch(this, 'mail.group');
this.res_users = new data.DataSetSearch(this, 'res.users');
this.groups = [];
},
start: function () {
this._super.apply(this, arguments);
return this.fetch_suggested_groups();
},
fetch_suggested_groups: function () {
var self = this;
var group = self.mail_group.call('get_suggested_thread', {'removed_suggested_threads': removed_suggested_group}).then(function (res) {
_(res).each(function (result) {
result.image = real_session.url('/web/binary/image', {model: 'mail.group', field: 'image_small', id: result.id});
});
self.groups = res;
});
return $.when(group).then(this.proxy('display_suggested_groups'));
},
display_suggested_groups: function () {
var suggested_groups = this.$('.oe_sidebar_suggestion.oe_suggestion_group');
if (suggested_groups) {
suggested_groups.empty();
}
if (this.groups.length === 0) {
return this.$el.empty();
}
return this.$el.empty().html(QWeb.render('TimelineSuggestionGroups', {'widget': this}));
},
join_group: function (event) {
var self = this;
var group_id = parseInt($(event.currentTarget).attr('id'), 10);
return this.mail_group.call('message_subscribe_users', [[group_id], [this.session.uid]]).then(function(res) {
self.fetch_suggested_groups();
});
},
remove_group_suggestion: function (event) {
removed_suggested_group.push($(event.currentTarget).attr('id'));
return this.fetch_suggested_groups();
},
stop_group_suggestion: function (event) {
var self = this;
return this.res_users.call('stop_showing_groups_suggestions', [this.session.uid]).then(function(res) {
self.$(".oe_sidebar_suggestion.oe_suggestion_group").hide();
});
}
});
mail.Sidebar.include({
start: function () {
this._super.apply(this, arguments);
var sug_groups = new Groups(this);
return sug_groups.appendTo(this.$('.oe_suggestions_groups'));
},
});
});
-7
View File
@@ -26,9 +26,6 @@
<div t-name="TimelineWall" t-attf-class="o_timeline #{widget.options.view_inbox ? 'o_timeline_inbox' : 'o_timeline_chatter'}">
<div class="o_timeline_buttons"/>
<div class="o_timeline-placeholder"></div>
<t t-if="widget.options.view_inbox">
<aside class="o_timeline_inbox_aside"></aside>
</t>
</div>
<t t-name="ComposeMessage">
@@ -246,10 +243,6 @@
<div class="oe_view_nocontent">No message.</div>
</t>
<t t-name="TimelineSidebar">
<div class="o_timeline_sidebar"></div>
</t>
<!--
ComposeMessage.ButtonTopBar
render of the button on the user bar for open wizard compose message
@@ -1,38 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<template>
<!-- Groups placeholder in sidebar -->
<t t-extend="TimelineSidebar">
<t t-jquery=".o_timeline_sidebar" t-operation="append">
<div class="oe_suggestions_groups"></div>
</t>
</t>
<!-- Suggested groups -->
<div t-name="TimelineSuggestionGroups" class="oe_sidebar_suggestion oe_suggestion_group">
<div class="oe_suggest_title">
<i class="oe_suggestion_remove oe_suggestion_group fa fa-times"/>
<span>Suggested Groups</span>
</div>
<div class="oe_suggest_items">
<t t-foreach="widget.groups" t-as="result">
<div class="oe_suggested_item">
<div class="oe_suggested_item_image">
<a t-attf-href="#model=mail.group&amp;id=#{result.id}">
<img t-att-src="result.image" t-att-alt="result.name"/>
</a>
</div>
<div class="oe_suggested_item_content">
<a class="oe_suggestion_item_name" t-attf-href="#model=mail.group&amp;id=#{result.id}"><t t-esc="result.name"/></a>
<i class="oe_suggestion_remove_item oe_suggestion_group fa fa-times" t-att-id="result.id"/>
<br/>
<div class="btn-group btn-group-sm">
<button type="button" class="btn btn-default oe_suggestion_join" t-att-id="result.id">Join Group</button>
</div>
</div>
</div>
</t>
</div>
</div>
</template>
-1
View File
@@ -11,7 +11,6 @@
<script type="text/javascript" src="/mail/static/src/js/mail_followers.js"></script>
<script type="text/javascript" src="/mail/static/src/js/many2many_tags_email.js"></script>
<script type="text/javascript" src="/mail/static/src/js/announcement.js"></script>
<script type="text/javascript" src="/mail/static/src/js/suggestions.js"></script>
</xpath>
</template>
</data>
-1
View File
@@ -50,7 +50,6 @@
</div>
<field name="alias_contact" string="Alias Accepts Emails From"
attrs="{'invisible': [('alias_domain', '=', False)]}"/>
<field name="display_groups_suggestions" groups="base.group_no_one"/>
</field>
</data>
</field>