[MERGE] merge trunk-social-tde branch.

bzr revid: bth@tinyerp.com-20120229053432-ps03fdczspj8zr9w
This commit is contained in:
Bhumi Thakkar (Open ERP)
2012-02-29 11:04:32 +05:30
10 changed files with 371 additions and 159 deletions
+2 -3
View File
@@ -288,8 +288,7 @@ class crm_base(object):
data = {'state': 'open', 'active': True}
if not case.user_id:
data['user_id'] = uid
self.write(cr, uid, case.id, data)
self._case_open_notification(case, context=context)
self.write(cr, uid, [case.id], data)
self._action(cr, uid, cases, 'open')
return True
@@ -418,7 +417,7 @@ class crm_case(crm_base):
data = {'state': 'open', 'active': True }
if not case.user_id:
data['user_id'] = uid
self.write(cr, uid, case.id, data)
self.write(cr, uid, [case.id], data)
self._case_open_notification(case, context=context)
self._action(cr, uid, cases, 'open')
return True
@@ -138,7 +138,7 @@ class crm_lead_forward_to_partner(osv.osv_memory):
if email_to not in new_cc:
new_cc.append(to)
update_vals = {'email_cc' : ', '.join(new_cc) }
lead.write(cr, uid, case.id, update_vals, context=context)
lead.write(cr, uid, [case.id], update_vals, context=context)
return res
def _get_info_body_text(self, cr, uid, lead, context=None):
+8 -4
View File
@@ -358,12 +358,16 @@ class hr_holidays(osv.osv):
# OpenChatter and notifications
# -----------------------------
def message_get_subscribers(self, cr, uid, ids, context=None):
sub_ids = self._message_get_subscribers_ids(cr, uid, ids, context=context);
# add the employee and its manager if specified to the subscribed users
for obj in self.browse(cr, uid, ids, context=context):
if obj.employee_id.parent_id:
sub_ids.append(obj.employee_id.parent_id.user_id.id)
return self.pool.get('res.users').read(cr, uid, sub_ids, context=context)
def create_notificate(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context):
# add the employee and its manager if specified to the subscribed users
self.message_subscribe(cr, uid, ids, [obj.employee_id.user_id.id], context=context)
if obj.employee_id.parent_id:
self.message_subscribe(cr, uid, ids, [obj.employee_id.parent_id.user_id.id], context=context)
self.message_append_note(cr, uid, ids, _('System notification'),
_("The %s request '%s' has been created and is waiting confirmation")
% ('leave' if obj.type == 'remove' else 'allocation', obj.name), type='notification', context=context)
@@ -68,7 +68,7 @@ class hr_recruitment_partner_create(osv.osv_memory):
'email': case.email_from
}, context=context)
case_obj.write(cr, uid, case.id, {
case_obj.write(cr, uid, [case.id], {
'partner_id': partner_id,
'partner_address_id': contact_id
}, context=context)
@@ -88,4 +88,4 @@ class hr_recruitment_partner_create(osv.osv_memory):
hr_recruitment_partner_create()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+1
View File
@@ -72,6 +72,7 @@ The main features are:
'images/customer_history.jpeg',
'images/messages_form.jpeg',
'images/messages_list.jpeg',
'static/src/img/email_icong.png',
],
'css': [
'static/src/css/mail.css',
+25 -10
View File
@@ -68,6 +68,21 @@ class mail_thread(osv.osv):
),
#widget='mail.ThreadView'),
}
#------------------------------------------------------
# Automatic subscription when creating/reading
#------------------------------------------------------
def create(self, cr, uid, vals, context=None):
thread_id = super(mail_thread, self).create(cr, uid, vals, context=context);
self.message_subscribe(cr, uid, [thread_id], [uid], context=context)
return thread_id;
def write(self, cr, uid, ids, vals, context=None):
write_res = super(mail_thread, self).write(cr, uid, ids, vals, context=context);
if write_res:
self.message_subscribe(cr, uid, ids, [uid], context=context)
return write_res;
#------------------------------------------------------
# Generic message api
@@ -597,21 +612,21 @@ class mail_thread(osv.osv):
users = self.pool.get('res.users').read(cr, uid, user_ids, fields=['id', 'name', 'avatar_mini'], context=context)
return users
def message_is_subscriber(self, cr, uid, ids, context=None):
# TODO: use message_get_subscribers ? as all subscriptions are in mail.subscription table, not necessary
subscription_obj = self.pool.get('mail.subscription')
sub_ids = subscription_obj.search(cr, uid,
['&', '&', ('res_model', '=', self._name), ('res_id', 'in', ids), ('user_id', '=', uid)], context=context)
if len(sub_ids) > 1:
pass # TODO
return True if sub_ids else False
def message_is_subscriber(self, cr, uid, ids, user_id = None, context=None):
users = self.message_get_subscribers(cr, uid, ids, context=context)
sub_user_id = uid if user_id is None else user_id
if sub_user_id in [user['id'] for user in users]:
return True
return False
def message_subscribe(self, cr, uid, ids, user_ids = None, context=None):
subscription_obj = self.pool.get('mail.subscription')
sub_user_ids = [uid] if user_ids is None else user_ids
create_ids = []
for id in ids:
create_ids = [subscription_obj.create(cr, uid, {'res_model': self._name, 'res_id': id, 'user_id': user_id}, context=context)
for user_id in sub_user_ids]
for user_id in sub_user_ids:
if self.message_is_subscriber(cr, uid, [id], user_id=user_id, context=context): continue
create_ids.append(subscription_obj.create(cr, uid, {'res_model': self._name, 'res_id': id, 'user_id': user_id}, context=context))
return create_ids
def message_unsubscribe(self, cr, uid, ids, context=None):
+41 -10
View File
@@ -20,6 +20,11 @@
margin-left: 5%;
}
.oe_mail_wall_thread_content div.oe_mail_thread_act .oe_mail_action_textarea {
width: 100%;
height: 20px;
padding: 2px;
}
/* Thread */
@@ -77,8 +82,26 @@
}
.oe_mail_thread_msg, .oe_mail_thread_act {
width: 80%;
white-space: normal;
margin-bottom: 5px;
border-bottom: 1px solid #D2D9E7;
}
.notification {
background: #E0E0E0;
}
.email {
background: #E0E0E0;
}
.oe_mail_thread_msg_more {
margin-left: 20%;
margin-right: 40%;
border: 1px solid #D2D9E7;
background: #E0E0E0;
text-align: center;
}
.oe_mail_thread_msg:after, .oe_mail_thread_act:after {
@@ -92,15 +115,15 @@
}
.oe_mail_action_textarea {
width: 60%;
width: 80%;
height: 50px;
padding: 5px;
}
.oe_mail_msg_image {
float: left;
width: 60px;
height: 60px;
width: 45px;
height: 40px;
text-align: center;
overflow: hidden;
-moz-border-radius: 3px;
@@ -115,14 +138,13 @@
}
.oe_mail_msg_image img {
width: 60px;
width: 40px;
height: auto;
clip: rect(10px, 100px, 110px, 0px);
}
.oe_mail_msg_content {
width: 89%;
margin-left: 11%;
margin-left: 50px;
}
.oe_mail_msg_p {
@@ -130,10 +152,19 @@
margin: 0;
}
.oe_mail_msg_body {
.oe_mail_msg_p_email_header {
border-bottom: 1px solid #D2D9E7;
}
.oe_mail_msg_author, .oe_mail_msg_author a {
.oe_mail_msg_body a.reduce, .oe_mail_msg_body_short a.expand {
color: #4E43E7;
}
.oe_mail_msg_author {
color: #747474;
}
.oe_mail_msg_author a {
color: #4E43E7;
}
@@ -141,6 +172,6 @@
color: #C03000;
}
.oe_mail_msg_date, .oe_mail_msg_date a {
color: #4E43E7;
.oe_mail_msg_date {
color: #747474;
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

+237 -103
View File
@@ -10,18 +10,30 @@ openerp.mail = function(session) {
/* ThreadDisplay widget: display a thread of comments */
mail.ThreadDisplay = session.web.Widget.extend({
// QWeb template to use when rendering the object
template: 'ThreadDisplay',
/**
*
* @params {Object} parent parent
* @params {Object} [params]
* @param {String} [params.res_model] res_model of mail.thread object
* @param {Number} [params.res_id] res_id of record
* @param {Number} [params.uid] user id
* @param {Number} [params.char_show_more=100] number of character to display before adding a "show more"
* @param {Number} [params.limit=10] maximum number of messages to fetch
* @param {Number} [params.offset=0] offset for fetchign messages
* @param {Number} [params.records=null] records to show instead of fetching messages
*/
init: function(parent, params) {
this._super(parent);
this.res_model = params['res_model'];
this.res_id = params['res_id'];
this.uid = params['uid'];
this.records = params['records'] || false;
this.map_hash = {'res.users': []};
/* DataSets */
this.ds = new session.web.DataSet(this, this.res_model);
this.params = params;
this.params.limit = this.params.limit || 10;
this.params.offset = this.params.offset || 0;
this.params.records = this.params.records || null;
this.params.char_show_more = this.params.char_show_more || 100;
this.map_hash = {'res.users': {'login': [] }};
/* define DataSets */
this.ds = new session.web.DataSet(this, this.params.res_model);
this.ds_users = new session.web.DataSet(this, 'res.users');
},
@@ -31,116 +43,147 @@ openerp.mail = function(session) {
/* bind buttons */
this.$element.find('button.oe_mail_button_comment').bind('click', function () { self.do_comment(); });
/* delegate links */
self.$element.find('div.oe_mail_thread_display').delegate('a', 'click', function (event) {
//console.log(event);
var res_model = event.srcElement.dataset.resModel;
var res_id = event.srcElement.dataset.resId;
self.$element.find('div.oe_mail_thread_display').delegate('a.intlink', 'click', function (event) {
self.do_action({
type: 'ir.actions.act_window',
res_model: res_model,
res_id: parseInt(res_id),
//context: context,
res_model: event.srcElement.dataset.resModel,
res_id: parseInt(event.srcElement.dataset.resId),
views: [[false, 'form']]
});
});
/* display user, fetch comments */
this.display_current_user();
if (this.records == false) this.fetch_comments();
else this.display_comments(this.records);
if (this.params.records) return this.display_comments(this.params.records);
else return this.init_comments();
},
stop: function () {
this._super.apply(this, arguments);
},
fetch_comments: function () {
var load_res = this.ds.call('message_load', [[this.res_id]]).then(
init_comments: function() {
var self = this;
this.params.offset = 0;
this.$element.find('div.oe_mail_thread_display').empty();
return this.fetch_comments().then(function () {
self.$element.find('button.oe_mail_button_more').bind('click', function () { self.do_more(); });
});
},
fetch_comments: function (limit, offset) {
return this.ds.call('message_load', [[this.params.res_id], limit=(limit||this.params.limit), offset=(offset||this.params.offset)]).then(
this.proxy('display_comments'));
return load_res;
},
display_comments: function (records) {
var self = this;
/* WIP: map matched regexp -> records to browse with name */
//_(records).each(function (record) {
//self.do_check_internal_links(record.body_text);
//});
_(records).each(function (record) {
if (record.type == 'email') { record.mini_url = ('/mail/static/src/img/email_icon.png'); }
else { record.mini_url = self.thread_get_avatar_mini('res.users', 'avatar_mini', record.user_id[0]); }
// body text manipulation
record.body_text = self.do_clean_text(record.body_text);
record.tr_body_text = self.do_truncate_string(record.body_text, self.params.char_show_more);
record.body_text = self.do_replace_internal_links(record.body_text);
if (record.tr_body_text) record.tr_body_text = self.do_replace_internal_links(record.tr_body_text);
// render
$(session.web.qweb.render('ThreadMsg', {'record': record})).appendTo(self.$element.find('div.oe_mail_thread_display'));
// truncated: hide full-text, show summary, add buttons
if (record.tr_body_text) {
var node = self.$element.find('span.oe_mail_msg_body:last').append(' <a href="#" class="reduce">[ ... Show less]</a>');
self.$element.find('p.oe_mail_msg_p:last').append($('<span class="oe_mail_msg_body_short">' + record.tr_body_text + ' <a href="#" class="expand">[ ... Show more]</a></span>'));
var new_node = self.$element.find('span.oe_mail_msg_body_short:last');
node.hide();
node.find('a:last').click(function() { node.hide(); new_node.show(); return false; });
new_node.find('a:last').click(function() { new_node.hide(); node.show(); return false; });
}
});
// update offset for "More" buttons
this.params.offset += records.length;
},
display_current_user: function () {
$('<div>').html(
'<img src="' + this.thread_get_avatar_mini('res.users', 'avatar_mini', this.uid) + '"/>'
'<img src="' + this.thread_get_avatar_mini('res.users', 'avatar_mini', this.params.uid) + '"/>'
).appendTo(this.$element.find('div.oe_mail_msg_image'));
},
display_comments: function (records) {
this.$element.find('div.oe_mail_thread_display').empty();
var self = this;
/* WIP: map matched regexp -> records to browse with name */
_(records).each(function (record) {
self.check_internal_links(record.body_text);
});
//console.log(this.map_hash);
_(records).each(function (record) {
record.mini_url = self.thread_get_avatar_mini('res.users', 'avatar_mini', record.user_id[0]);
record.body_text = self.do_replace_internal_links(record.body_text);
var render_res = session.web.qweb.render('ThreadMsg', {
'record': record,
});
$('<div class="oe_mail_thread_msg">').html(render_res).appendTo(self.$element.find('div.oe_mail_thread_display'));
});
},
do_comment: function () {
var body_text = this.$element.find('textarea').val();
return this.ds.call('message_append_note', [[this.res_id], 'Reply comment', body_text, type='comment']).then(
this.proxy('fetch_comments'));
return this.ds.call('message_append_note', [[this.params.res_id], 'Reply comment', body_text, type='comment']).then(
this.proxy('init_comments'));
},
/* check for internal links, and map them to limitate number of queries -- WIP, probably not useful */
check_internal_links: function(string) {
/* shortcut to user: @login */
var regex_login = new RegExp(/(^|\s)@(\w*[a-zA-Z_.]+\w*\s)/g);
var regex_res = regex_login.exec(string);
while (regex_res != null) {
var login = regex_res[2];
this.map_hash['res.users'].push(login);
regex_res = regex_login.exec(string);
}
/* internal links: @res.model,name */
var regex_intlink = new RegExp(/(^|\s)@(\w*[a-zA-Z_]+\w*)\.(\w+[a-zA-Z_]+\w*),(\w+)/g);
regex_res = regex_intlink.exec(string);
while (regex_res != null) {
var res_model = regex_res[2] + '.' + regex_res[3];
var res_name = regex_res[4];
if (! (res_model in this.map_hash)) { this.map_hash[res_model] = []; }
this.map_hash[res_model].push(res_name);
regex_res = regex_intlink.exec(string);
}
do_more: function () {
return this.fetch_comments(this.limit, this.offset);
},
do_replace_internal_links: function (string) {
var self = this;
/* internal links: @sale.order,32 */
var regex_intlink = new RegExp(/(^|\s)@(\w*[a-zA-Z_]+\w*)\.(\w+[a-zA-Z_]+\w*),(\d+)/g);
var regex_res = regex_intlink.exec(string);
while (regex_res != null) {
var res_model = regex_res[2] + '.' + regex_res[3];
var res_id = regex_res[4];
string = string.replace(regex_res[0], '' + regex_res[1] + '<a href="#" data-res-model = ' + res_model + ' data-res-id = ' + res_id + '>'
+ res_model + '(' + res_id + ')</a>');
regex_res = regex_intlink.exec(string);
}
/* shortcut to user: @login */
//var regex_login = new RegExp(/(^|\s)@(\w*[a-zA-Z_.]+\w*)/g);
//var regex_res = regex_login.exec(string);
//while (regex_res != null) {
//var res_model = regex_res[2] + '.' + regex_res[3];
//var res_id = regex_res[4];
//string = string.replace(regex_res[0], '' + regex_res[1] + '<a href="#" data-res-model = ' + res_model + ' data-res-id = ' + res_id + '>'
//+ res_model + '(' + res_id + ')</a>');
//regex_res = regex_intlink.exec(string);
//}
var regex_login = new RegExp(/(^|\s)@(\w*)/g);
var regex_res = regex_login.exec(string);
while (regex_res != null) {
var login = regex_res[2];
var res_id = 1;
//var user_loaded = this.ds_users.call('search', [[['login', 'in', [login]]]]).then(function (records) {
//console.log(records);
//if (records) string = string.replace(regex_res[0], '<a href="#" class="intlink" data-res-model="res.users" data-res-id = ' + records[0] + '>@' + login + '</a>');
//});
//$.when(user_loaded).then(function() {
//});
regex_res = regex_login.exec(string);
}
return string;
},
thread_get_avatar_mini: function(model, field, id) {
id = id || '';
var url = this.session.prefix + '/web/binary/image?session_id=' + this.session.session_id + '&model=' + model + '&field=' + field + '&id=' + id;
return url;
return this.session.prefix + '/web/binary/image?session_id=' + this.session.session_id + '&model=' + model + '&field=' + field + '&id=' + (id || '');
},
do_truncate_string: function(string, max_length) {
if (string.length <= max_length) return false;
else return string.slice(0, max_length);
},
do_clean_text: function (string) {
var html = $('<div/>').text(string.replace(/\s+/g, ' ')).html().replace(new RegExp('&lt;(/)?b\\s*&gt;', 'gi'), '<$1b>');
return html;
},
/**
*
* var regex_login = new RegExp(/(^|\s)@(\w*[a-zA-Z_.]+\w*\s)/g);
* var regex_login = new RegExp(/(^|\s)@(\w*)/g);
* var regex_intlink = new RegExp(/(^|\s)#(\w*[a-zA-Z_]+\w*)\.(\w+[a-zA-Z_]+\w*),(\w+)/g);
*/
do_check_internal_links: function(string) {
/* shortcut to user: @login */
var regex_login = new RegExp(/(^|\s)@(\w*)/g);
var regex_res = regex_login.exec(string);
while (regex_res != null) {
var login = regex_res[2];
this.map_hash['res.users']['login'].push(login);
regex_res = regex_login.exec(string);
}
/* internal links: #res.model,name */
var regex_intlink = new RegExp(/(^|\s)#(\w*[a-zA-Z_]+\w*)\.(\w+[a-zA-Z_]+\w*),(\w+)/g);
regex_res = regex_intlink.exec(string);
while (regex_res != null) {
var res_model = regex_res[2] + '.' + regex_res[3];
var res_name = regex_res[4];
if (! (res_model in this.map_hash)) { this.map_hash[res_model]['name'] = []; }
this.map_hash[res_model]['name'].push(res_name);
regex_res = regex_intlink.exec(string);
}
},
});
@@ -251,13 +294,23 @@ openerp.mail = function(session) {
/* WallView widget: a wall of messages */
mail.WallView = session.web.Widget.extend({
// QWeb template to use when rendering the object
template: 'Wall',
/**
* @param {Object} parent parent
* @param {Object} [params]
* @param {Number} [params.limit=20] number of messages to show and fetch
* @var {Array} sorted_comments records sorted by res_model and res_id
* records.res_model = {res_ids}
* records.res_model.res_id = [records]
*/
init: function (parent, params) {
this._super(parent);
this.filter_search = params['filter_search'];
this.search = {}
this.params = params || {};
this.params.limit = params.limit || 20;
this.params.search = {};
this.params.domain = [];
this.sorted_comments = {};
/* DataSets */
this.ds_msg = new session.web.DataSet(this, 'mail.message');
this.ds_thread = new session.web.DataSet(this, 'mail.thread');
@@ -274,19 +327,33 @@ openerp.mail = function(session) {
self.searchview.on_search.add(self.do_searchview_search);
});
/* fetch comments */
var comments_ready = this.fetch_comments();
var comments_ready = this.init_comments();
return (search_view_ready && comments_ready);
},
stop: function () {
this._super.apply(this, arguments);
},
/**
* Loads the mail.message search view
* @param {Number} view_id id of the search view to load
* @param {??} defaults ??
* @param {Boolean} hidden ??
*/
load_search_view: function (view_id, defaults, hidden) {
this.searchview = new session.web.SearchView(this, this.ds_msg, view_id || false, defaults || {}, hidden || false);
return this.searchview.appendTo(this.$element.find('div.oe_mail_wall_search'));
},
/**
* Aggregate the domains, contexts and groupbys in parameter
* with those from search form, and then calls fetch_comments
* to actually fetch comments
* @param {Array} domains
* @param {Array} contexts
* @param {Array} groupbys
*/
do_searchview_search: function(domains, contexts, groupbys) {
var self = this;
this.rpc('/web/session/eval_domain_and_context', {
@@ -294,25 +361,51 @@ openerp.mail = function(session) {
contexts: contexts || [],
group_by_seq: groupbys || []
}, function (results) {
self.search['context'] = results.context;
self.search['domain'] = results.domain;
self.search['groupby'] = results.group_by;
self.fetch_comments(self.search['domain'], self.search['context']);
self.params.search['context'] = results.context;
self.params.search['domain'] = results.domain;
self.params.search['groupby'] = results.group_by;
self.init_comments(self.params.search['domain'], self.params.search['context']);
});
},
/**
* Initializes Wall and calls fetch_comments
* @param {Array} domains
* @param {Array} contexts
* @param {Array} groupbys
* @param {Number} limit number of messages to fetch
*/
init_comments: function(domain, context, offset, limit) {
var self = this;
this.params.domain = [];
this.sorted_comments = {};
this.$element.find('div.oe_mail_wall_threads').empty();
return this.fetch_comments(domain, context, offset, limit).then(function () {
self.$element.find('button.oe_mail_wall_button_more').bind('click', function () { self.do_more(); });
});
},
/**
* Fetches Wall comments (mail.thread.get_pushed_messages)
* @param {Array} domains
* @param {Array} contexts
* @param {Array} groupbys
* @param {Number} limit number of messages to fetch
*/
fetch_comments: function (domain, context, offset, limit) {
var load_res = this.ds_thread.call('get_pushed_messages',
[[this.session.uid], limit = (limit || 100), offset = (offset || 0), domain = (domain || null), context = (context || null) ]).then(
this.proxy('display_comments'));
return load_res;
},
/**
* @param {Array} records records to show in threads
*/
display_comments: function (records) {
this.$element.find('div.oe_mail_wall_threads').empty();
sorted_records = this.sort_comments(records);
var sorted_comments = this.sort_comments(records, this.sorted_comments);
var self = this;
_(sorted_records).each(function (rec_models, model) { // each model
_(sorted_comments).each(function (rec_models, model) { // each model
_(rec_models).each(function (record_id, id) { // each record
var template = 'WallThreadContainer';
var render_res = session.web.qweb.render(template, {
@@ -320,16 +413,24 @@ openerp.mail = function(session) {
'record_id': id,
});
$('<div class="oe_mail_wall_thread">').html(render_res).appendTo(self.$element.find('div.oe_mail_wall_threads'));
self.thread_display = new mail.ThreadDisplay(self,
var thread_display = new mail.ThreadDisplay(self,
{'res_model': model, 'res_id': parseInt(id), 'uid': self.session.uid, 'records': record_id}
);
self.thread_display.appendTo(self.$element.find('div.oe_mail_wall_thread_content:last'));
thread_display.appendTo(self.$element.find('div.oe_mail_wall_thread_content:last'));
});
});
$.extend(true, this.sorted_comments, sorted_comments);
},
/**
* Add records to sorted_comments array
* @param {Array} records records from mail.message
* @returns {Object} sorted_comments: dict
* sorted_comments.res_model = {res_ids}
* sorted_comments.res_model.res_id = [records]
*/
sort_comments: function (records) {
sorted_comments = {};
sorted_comments = {}
_(records).each(function (record) {
if (! (record.model in sorted_comments)) { sorted_comments[record.model] = {}; }
if (! (record.res_id in sorted_comments[record.model])) {
@@ -339,12 +440,45 @@ openerp.mail = function(session) {
return sorted_comments;
},
/**
* Create a domain to fetch new comments according to
* comment already present in sorted_comments
* @param {Object} sorted_comments (see sort_comments)
* @returns {Array} fetch_domain (OpenERP domain style)
*/
get_fetch_domain: function (sorted_comments) {
var domain = [];
_(sorted_comments).each(function (rec_models, model) { //each model
var ids = [];
_(rec_models).each(function (record_id, id) { // each record
ids.push(id);
});
domain.push('|', ['model', '!=', model], ['res_id', 'not in', ids]);
});
return domain;
},
/**
* Action: Posts a comment
*/
do_comment: function () {
var body_text = this.$element.find('textarea').val();
return this.ds_users.call('message_append_note', [[this.session.uid], 'Tweet', body_text, type='comment']).then(
this.proxy('fetch_comments'));
//this.proxy('fetch_comments'));
this.init_comments());
},
/**
* Action: Shows more discussions
*/
do_more: function () {
var domain = this.get_fetch_domain(this.sorted_comments);
return this.fetch_comments(domain);
},
/**
* Tools: get avatar mini (TODO: should be moved in some tools ?)
*/
thread_get_mini: function(model, field, id) {
id = id || '';
var url = this.session.prefix + '/web/binary/image?session_id=' + this.session.session_id + '&model=' + model + '&field=' + field + '&id=' + id;
+54 -26
View File
@@ -13,6 +13,11 @@
</div>
<div class="oe_mail_wall_threads">
</div>
<div class="oe_mail_wall_more">
<button class="oe_mail_wall_button_more" type="button">See more discussions
<t t-if="msg_left"> (<t t-raw="msg_left"/> left)</t>
</button>
</div>
</div>
<div class="oe_mail_wall_right">
<div class="oe_mail_followers">
@@ -57,44 +62,67 @@
<div class="oe_mail_msg_image">
</div>
<div class="oe_mail_msg_content">
<textarea class="oe_mail_action_textarea" onfocus="this.value='';">Enter your comment here...</textarea><br />
<button type="button" class="oe_mail_button_comment">Post comment</button>
<textarea class="oe_mail_action_textarea" onfocus="this.value='';">Enter your comment here...</textarea><br />
<button type="button" class="oe_mail_button_comment">Post comment</button>
</div>
</div>
<div class="oe_mail_thread_display">
</div>
<div class="oe_mail_thread_more">
<div class="oe_mail_thread_msg">
<t t-call="MoreButton"/>
</div>
</div>
</div>
<t t-name="ThreadMsg">
<div t-name="ThreadMsg" t-attf-class="{record.type} oe_mail_thread_msg">
<div class="oe_mail_msg_image">
<img t-att-src="record.mini_url"/>
</div>
<div class="oe_mail_msg_content">
<p class="oe_mail_msg_p">
<t t-if="record.type == 'notification'">
<span class="oe_mail_msg_author">OpenERP System Notification</span>
</t>
<t t-if="record.type == 'comment'">
<span class="oe_mail_msg_author"><a href="#"><t t-raw="record.user_id[1]"/></a></span>
</t>
<t t-if="record.type == 'email'">
<span class="oe_mail_msg_author"><t t-raw="record.user_id[1]"/></span>
</t>
<t t-if="record.need_action_user_id != false">
- <span class="oe_mail_msg_need_action">Need action by <a href="#"><t t-raw="record.need_action_user_id[1]"/></a></span>
</t>
<br />
<span class="oe_mail_msg_body"><t t-esc="record.body_text"/></span><br />
<span class="oe_mail_msg_date"><t t-raw="record.date"/></span>
</p>
<t t-if="record.type == 'email'">
<t t-call="EmailDisplay" />
</t>
<t t-if="record.type == 'notification' || record.type == 'comment'">
<t t-call="NotificationDisplay" />
</t>
</div>
</div>
<t t-name="NotificationDisplay">
<p class="oe_mail_msg_p">
<t t-if="record.type == 'notification'">
<span class="oe_mail_msg_author">OpenERP System Notification</span>
</t>
<t t-if="record.type == 'comment'">
<span class="oe_mail_msg_author">
<a href="#" data-res-model='res.users' t-attf-data-res-id='{record.user_id[0]}'><t t-raw="record.user_id[1]"/></a>
</span>
</t>
<t t-if="record.need_action_user_id != false">
- <span class="oe_mail_msg_need_action">Need action by <a href="#"><t t-raw="record.need_action_user_id[1]"/></a></span>
</t>
wrote on <span class="oe_mail_msg_date"><t t-raw="record.date"/></span>
<br />
<span class="oe_mail_msg_body"><t t-raw="record.body_text"/></span>
</p>
</t>
<t t-name="WallHeader">
<div class="tmp_oe_mail_thread_header">
Discussion about document <t t-raw="record_model"/> (id: <t t-raw="record_id"/>)
</div>
<div class="tmp_oe_mail_thread_content">
<t t-name="EmailDisplay">
<p class="oe_mail_msg_p oe_mail_msg_p_email_header">
From: <t t-esc="email_from"/> on <span class="oe_mail_msg_date"><t t-raw="record.date"/></span><br />
To: <t t-sec="mail_to"/><br />
</p>
<p class="oe_mail_msg_p">
<span class="oe_mail_msg_body"><t t-raw="record.body_text"/></span>
</p>
</t>
<t t-name="MoreButton">
<div class="oe_mail_thread_msg_more">
<button class="oe_mail_button_more" type="button">More
<t t-if="msg_left"> (<t t-raw="msg_left"/> left)</t>
</button>
</div>
</t>