@@ -84,12 +82,8 @@
-
-
-
-
diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py
index 97e78cfdd15..71d4bfd099b 100644
--- a/addons/mail/mail_thread.py
+++ b/addons/mail/mail_thread.py
@@ -169,6 +169,7 @@ class mail_thread(osv.AbstractModel):
for subtype in fol.subtype_ids:
thread_subtype_dict[subtype.name]['followed'] = True
res[fol.res_id]['message_subtype_data'] = thread_subtype_dict
+
return res
def _search_unread(self, cr, uid, obj=None, name=None, domain=None, context=None):
@@ -679,6 +680,11 @@ class mail_thread(osv.AbstractModel):
partner_ids = [user.partner_id.id for user in self.pool.get('res.users').browse(cr, uid, user_ids, context=context)]
return self.message_subscribe(cr, uid, ids, partner_ids, subtype_ids=subtype_ids, context=context)
+ def get_message_subtypes(self, cr, uid, ids, context=None):
+ """ message_subtype_data: data about document subtypes: which are
+ available, which are followed if any """
+ return self._get_subscription_data(cr, uid, ids, None, None, context=context)
+
def message_subscribe(self, cr, uid, ids, partner_ids, subtype_ids=None, context=None):
""" Add partners to the records followers. """
self.write(cr, uid, ids, {'message_follower_ids': [(4, pid) for pid in partner_ids]}, context=context)
diff --git a/addons/mail/res_partner_view.xml b/addons/mail/res_partner_view.xml
index 3ef68ac8c59..2a8430926d5 100644
--- a/addons/mail/res_partner_view.xml
+++ b/addons/mail/res_partner_view.xml
@@ -9,12 +9,8 @@
-
-
-
-
diff --git a/addons/mail/static/src/css/mail.css b/addons/mail/static/src/css/mail.css
index 895aa57bdc5..3fde4cbc67b 100644
--- a/addons/mail/static/src/css/mail.css
+++ b/addons/mail/static/src/css/mail.css
@@ -14,7 +14,6 @@
margin: 0;
}
-
/* ------------------------------------------------------------ */
/* Wall
/* ------------------------------------------------------------ */
@@ -37,6 +36,29 @@
list-style-type: none;
}
+/* ------------------------------------------------------------ */
+/* Followers
+/* ------------------------------------------------------------ */
+
+.openerp div.oe_mail_recthread_aside h4 {
+ display: inline-block;
+}
+.openerp div.oe_mail_recthread_aside button {
+ position: relative;
+}
+.openerp div.oe_mail_recthread_aside label,
+.openerp div.oe_mail_recthread_aside input {
+ cursor:pointer;
+}
+.openerp div.oe_mail_recthread_subtypes {
+ display:none;
+}
+.openerp div.oe_mail_recthread_aside button span {
+ position: absolute;
+ top:-7px;
+ right:5px;
+}
+
/* Specific display of threads in the wall */
/* ------------------------------------------------------------ */
@@ -113,15 +135,6 @@
margin-bottom: 8px;
}
-
-/* ------------------------------------------------------------ */
-/* Followers
-/* ------------------------------------------------------------ */
-
-.openerp div.oe_mail_recthread_aside h4 {
- display: inline-block;
-}
-
/* ------------------------------------------------------------ */
/* Thread
/* ------------------------------------------------------------ */
diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js
index 0efbf9ca76e..a3ba6f91a04 100644
--- a/addons/mail/static/src/js/mail_followers.js
+++ b/addons/mail/static/src/js/mail_followers.js
@@ -27,9 +27,9 @@ openerp_mail_followers = function(session, mail) {
this.options.image = this.node.attrs.image || 'image_small';
this.options.title = this.node.attrs.title || 'Followers';
this.ds_model = new session.web.DataSetSearch(this, this.view.model);
- this.sub_model = new session.web.DataSetSearch(this,'mail.message.subtype')
+ this.sub_model = new session.web.DataSetSearch(this,'mail.message.subtype');
this.ds_follow = new session.web.DataSetSearch(this, this.field.relation);
- this.follower_model = new session.web.DataSetSearch(this,'mail.followers')
+ this.follower_model = new session.web.DataSetSearch(this,'mail.followers');
},
start: function() {
@@ -51,11 +51,12 @@ openerp_mail_followers = function(session, mail) {
bind_events: function() {
var self = this;
- this.$el.find('button.oe_mail_button_unfollow').on('click', function () { self.do_unfollow(); })
- .mouseover(function () { $(this).html('Unfollow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); })
- .mouseleave(function () { $(this).html('Following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); });
- this.$el.on('click', 'button.oe_mail_button_follow', function () { self.do_follow(); });
- this.$el.on('click', 'ul.oe_mail_subtypes', function () {self.do_update_subscription(); })
+ this.$el.find('button.oe_mail_button_unfollow').on('click', function () { self.do_unfollow(); self.clear_subtypes(); })
+ .mouseover(function () { $(this).removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover').find('p').html('Unfollow');})
+ .mouseleave(function () { $(this).removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout').find('p').html('Following'); });
+
+ this.$el.on('click', 'button.oe_mail_button_follow', function () { self.do_follow(); self.clear_subtypes(); });
+ this.$el.on('click', 'ul.oe_mail_subtypes input', function () {self.do_update_subscription(); })
this.$el.on('click', 'button.oe_mail_button_invite', function(event) {
action = {
type: 'ir.actions.act_window',
@@ -71,37 +72,34 @@ openerp_mail_followers = function(session, mail) {
}
self.do_action(action, function() { self.read_value(); });
});
+
+ this.$el.find('button span')
+ .click(function (e) { self.display_subtypes(); e.stopPropagation(); })
},
read_value: function() {
var self = this;
- return this.ds_model.read_ids([this.view.datarecord.id], ['message_follower_ids', 'message_is_follower', 'message_subtype_data']).pipe(function (results) {
- self.set_value(results[0].message_follower_ids, results[0].message_is_follower, results[0].message_subtype_data);
+ return this.ds_model.read_ids([this.view.datarecord.id], ['message_follower_ids']).pipe(function (results) {
+ self.set_value(results[0].message_follower_ids);
});
},
- get_or_set: function(field_name, value) {
- if (this.view.fields[field_name]) {
- if (value !== undefined) {
- this.view.fields[field_name].set_value(value);
- }
- return this.view.fields[field_name].get_value();
- }
- else {
- return value;
- }
+ set_value: function(value_) {
+ console.log("set_value", value_);
+ this.reinit();
+ return this.fetch_followers(value_ || this.get_value());
},
- set_value: function(value_, message_is_follower_value_, message_subtype_data_value_) {
- this.reinit();
- if (! this.view.datarecord.id ||
- session.web.BufferedDataSet.virtual_id_regex.test(this.view.datarecord.id)) {
- this.$el.find('div.oe_mail_recthread_aside').hide();
- return;
+ set_is_follower: function(value_) {
+ for(var i in value_){
+ if(value_[i]['user_ids'][0]==this.session.uid)
+ this.message_is_follower=true;
+ this.display_buttons();
+ return true;
}
- this.message_is_follower_value_ = this.get_or_set('message_is_follower', message_is_follower_value_) || false;
- this.message_subtype_data_value_ = this.get_or_set('message_subtype_data', message_subtype_data_value_) || {};
- return this.fetch_followers(value_ || this.get_value());
+ this.message_is_follower=false;
+ this.display_buttons();
+ return false;
},
fetch_followers: function (value_, message_is_follower) {
@@ -136,12 +134,11 @@ openerp_mail_followers = function(session, mail) {
record.avatar_url = mail.ChatterUtils.get_image(self.session, 'res.partner', 'image_small', record.id);
$(session.web.qweb.render('mail.followers.partner', {'record': record})).appendTo(node_user_list);
});
- this.display_buttons();
- return this.display_subtypes(this.message_subtype_data_value_);
+ self.set_is_follower(records);
},
display_buttons: function () {
- if (this.message_is_follower_value_) {
+ if (this.message_is_follower) {
this.$el.find('button.oe_mail_button_follow').hide();
this.$el.find('button.oe_mail_button_unfollow').show();
}
@@ -156,24 +153,48 @@ openerp_mail_followers = function(session, mail) {
this.$el.find('span.oe_mail_invite_wrapper').show();
},
- /** Display subtypes: {'name': default, followed} */
- display_subtypes: function (records) {
- var subtype_list = this.$el.find('ul.oe_mail_subtypes').empty();
- if (! this.message_is_follower_value_) {
- return;
- }
+ set_subtypes:function(data){
+ var self = this;
+ var records = data[this.view.datarecord.id].message_subtype_data;
_(records).each(function (record, record_name) {
record.name = record_name;
record.followed = record.followed || undefined;
- $(session.web.qweb.render('mail.followers.subtype', {'record': record})).appendTo(subtype_list);
+ $(session.web.qweb.render('mail.followers.subtype', {'record': record})).appendTo( self.$el.find('ul.oe_mail_subtypes') );
});
},
-
+
+ /** Display subtypes: {'name': default, followed} */
+ display_subtypes: function () {
+ var self = this;
+ var recthread_subtypes = self.$el.find('.oe_mail_recthread_subtypes');
+ subtype_list_ul = self.$el.find('ul.oe_mail_subtypes');
+
+ if(recthread_subtypes.is(":visible")) {
+ self.hidden_subtypes();
+ } else {
+ if(subtype_list_ul.is(":empty")) {
+ var context = new session.web.CompoundContext(this.build_context(), {});
+ this.ds_model.call('get_message_subtypes',[[self.view.datarecord.id], context]).pipe(this.proxy('set_subtypes'));
+ }
+
+ recthread_subtypes.show();
+ }
+ },
+
+ clear_subtypes: function(){
+ this.$el.find('ul.oe_mail_subtypes').empty();
+ this.hidden_subtypes();
+ },
+
+ hidden_subtypes: function (){
+ this.$el.find('.oe_mail_recthread_subtypes').hide();
+ },
+
do_follow: function () {
var context = new session.web.CompoundContext(this.build_context(), {});
return this.ds_model.call('message_subscribe_users', [[this.view.datarecord.id], undefined, undefined, context]).pipe(this.proxy('read_value'));
},
-
+
do_unfollow: function () {
var context = new session.web.CompoundContext(this.build_context(), {});
return this.ds_model.call('message_unsubscribe_users', [[this.view.datarecord.id], undefined, context]).pipe(this.proxy('read_value'));
@@ -182,13 +203,15 @@ openerp_mail_followers = function(session, mail) {
do_update_subscription: function () {
var context = new session.web.CompoundContext(this.build_context(), {});
var self = this;
+
var checklist = new Array();
_(this.$el.find('.oe_msg_subtype_check')).each(function(record){
if($(record).is(':checked')) {
- checklist.push(parseInt($(record).attr('id')))}
+ checklist.push(parseInt($(record).data('id')))}
});
+
return this.ds_model.call('message_subscribe_users',[[self.view.datarecord.id], undefined, checklist, context]).pipe(this.proxy('read_value'));
},
});
-};
+};
\ No newline at end of file
diff --git a/addons/mail/static/src/xml/mail_followers.xml b/addons/mail/static/src/xml/mail_followers.xml
index 05eb349ea5d..9d0543bbdca 100644
--- a/addons/mail/static/src/xml/mail_followers.xml
+++ b/addons/mail/static/src/xml/mail_followers.xml
@@ -7,9 +7,9 @@
-->
-
-
-
+
+
+
Message types to follow
@@ -39,8 +39,8 @@
diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml
index b49123b8a38..d05893cf778 100644
--- a/addons/mrp/mrp_view.xml
+++ b/addons/mrp/mrp_view.xml
@@ -410,9 +410,6 @@
-
-
-
@@ -790,11 +787,7 @@
-
-
-
-
diff --git a/addons/mrp_operations/mrp_operations_view.xml b/addons/mrp_operations/mrp_operations_view.xml
index 715f0a53531..834f3000472 100644
--- a/addons/mrp_operations/mrp_operations_view.xml
+++ b/addons/mrp_operations/mrp_operations_view.xml
@@ -107,11 +107,7 @@
-
-
-
-
diff --git a/addons/mrp_repair/mrp_repair_view.xml b/addons/mrp_repair/mrp_repair_view.xml
index 94a06e6b40d..55cbe49c75b 100644
--- a/addons/mrp_repair/mrp_repair_view.xml
+++ b/addons/mrp_repair/mrp_repair_view.xml
@@ -189,11 +189,7 @@
-
-
-
-
diff --git a/addons/note/note_view.xml b/addons/note/note_view.xml
index 789a112b868..19eff9bc250 100644
--- a/addons/note/note_view.xml
+++ b/addons/note/note_view.xml
@@ -50,7 +50,6 @@
-
@@ -119,9 +118,6 @@
-
-
-
diff --git a/addons/procurement/procurement_view.xml b/addons/procurement/procurement_view.xml
index 64b10bd2bbf..bf73b383216 100644
--- a/addons/procurement/procurement_view.xml
+++ b/addons/procurement/procurement_view.xml
@@ -103,11 +103,7 @@
-
-
-
-
diff --git a/addons/product/product_view.xml b/addons/product/product_view.xml
index d175ea391d5..c08bbc412e3 100644
--- a/addons/product/product_view.xml
+++ b/addons/product/product_view.xml
@@ -203,11 +203,7 @@
-
-
-
-
diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml
index fa639f46c6d..93d01a5619b 100644
--- a/addons/project/project_view.xml
+++ b/addons/project/project_view.xml
@@ -152,11 +152,7 @@
-
-
-
-
@@ -482,11 +478,7 @@
-
-
-
-
diff --git a/addons/project_issue/project_issue_view.xml b/addons/project_issue/project_issue_view.xml
index f9e04e7420e..8d54520261f 100644
--- a/addons/project_issue/project_issue_view.xml
+++ b/addons/project_issue/project_issue_view.xml
@@ -161,11 +161,7 @@
-
-
-
-
diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml
index 69042a2fa1a..759c0561631 100644
--- a/addons/purchase/purchase_view.xml
+++ b/addons/purchase/purchase_view.xml
@@ -285,11 +285,7 @@
-
-
-
-
diff --git a/addons/purchase_requisition/purchase_requisition_view.xml b/addons/purchase_requisition/purchase_requisition_view.xml
index cba22f384ca..80bdd9aa95b 100644
--- a/addons/purchase_requisition/purchase_requisition_view.xml
+++ b/addons/purchase_requisition/purchase_requisition_view.xml
@@ -103,9 +103,6 @@
-
-
-
diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml
index 54fdcb8c140..5c2320a7d5c 100644
--- a/addons/sale/sale_view.xml
+++ b/addons/sale/sale_view.xml
@@ -351,11 +351,7 @@
-
-
-
-
diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml
index 2f2dc3a2d8a..83fed186f42 100644
--- a/addons/stock/stock_view.xml
+++ b/addons/stock/stock_view.xml
@@ -917,11 +917,7 @@
-
-
-
-
@@ -1047,11 +1043,7 @@
-
-
-
-