res[id]['message_summary'] = "<span class='oe_kanban_mail_new' title='%s'><span class='oe_e'>9</span> %d %s</span>" % (title, res[id].pop('message_unread_count'), _("New"))
return res
- def read_followers_data(self, cr, uid, ids, context=None):
- data = self.pool.get('res.partner').read(cr, uid, ids, ['name', 'user_ids'], context=context)
-
- grp_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'base', 'group_no_one')
- tech_user = self.pool.get('res.groups').read(cr, uid, grp_id[1], ['users'], context=context)['users']
- user_pid = self.pool.get('res.users').read(cr, uid, uid, ['partner_id'], context=context)['partner_id'][0]
-
- if uid in tech_user:
- for dict in data:
- if dict['id'] in [user_pid]:
- dict.update({'is_editable': True})
- if uid in dict['user_ids']:
- dict.update({'is_uid': True})
-
- return data
+ def read_followers_data(self, cr, uid, follower_ids, context=None):
+ datas = []
+ partner_pool = self.pool.get('res.partner')
+ technical_group = self.pool.get('ir.model.data').get_object(cr, uid, 'base', 'group_no_one')
+ for follower in partner_pool.browse(cr, uid, follower_ids, context=context):
+ is_editable = uid in map(lambda x:x.id, technical_group.users)
+ is_uid = uid in map(lambda x:x.id, follower.user_ids)
+ data = (
+ follower.id,
+ follower.name,
+ {'is_editable': is_editable, 'is_uid': is_uid},
+ )
+ datas.append(data)
+ return datas
def _get_subscription_data(self, cr, uid, ids, name, args, user_pid=None, context=None):
""" Computes:
this.followers = [];
this.view_is_editable = this.__parentedParent.is_action_enabled('edit');
- this.check_access = false;
- this.is_follower = false;
},
start: function() {
display_followers: function (records) {
var self = this;
this.followers = records || this.followers;
- _.each(this.result, function (record) {
- if (self.session.uid == record.user_ids[0]) {
- if (record.is_editable == true) { self.check_access = true; }
- }
- });
- this.message_is_follower = this.set_is_follower(this.followers); // self.is_follower
// clean and display title
var node_user_list = this.$('.oe_follower_list').empty();
this.$('.oe_follower_title').html(this._format_followers(this.followers.length));
// truncate number of displayed followers
var truncated = this.followers.slice(0, this.displayed_nb);
_(truncated).each(function (record) {
- record.avatar_url = mail.ChatterUtils.get_image(self.session, 'res.partner', 'image_small', record.id);
+ self.message_is_follower = record[2].is_uid;
+ record[2].avatar_url = mail.ChatterUtils.get_image(self.session, 'res.partner', 'image_small', record[0]);
$(session.web.qweb.render('mail.followers.partner', {'record': record, 'widget': self})).appendTo(node_user_list);
// On mouse-enter it will show the edit_subtype pencil.
- if (self.check_access == true) {
+ if (record[2].is_editable == true) {
self.$el.on('mouseenter', 'div.oe_follower_list', function() {
$("img.oe_edit_subtype").removeClass("hidden");
$('div.oe_follower_list').find('.oe_partner').addClass('oe_partner_name');
}
},
- /** Computes whether the current user is in the followers */
- set_is_follower: function (records) {
- var user_ids = _.pluck(_.pluck(records, 'user_ids'), 0);
- return _.indexOf(user_ids, this.session.uid) != -1;
- },
-
display_buttons: function () {
if (this.message_is_follower) {
this.$('button.oe_follower').removeClass('oe_notfollow').addClass('oe_following');
Template used to display a partner following the record
-->
<div t-name="mail.followers.partner" class='oe_partner'>
- <img class="oe_mail_thumbnail oe_mail_frame" t-attf-src="{record.avatar_url}"/>
- <a t-attf-href="#model=res.partner&id=#{record.id}" t-att-title="record.name"><t t-esc="record.name"/></a>
- <img t-if="widget.check_access and (widget.records_length > 1)" class="oe_edit_subtype hidden" t-att-src='_s + "/mail/static/src/img/icon-edit.gif"' title="Edit Subtype" t-att-data-id="record.id"/>
- <span t-if="widget.view_is_editable" class="oe_remove_follower oe_e" title="Remove this follower" t-att-data-id="record.id">X</span>
+ <img class="oe_mail_thumbnail oe_mail_frame" t-attf-src="{record[2].avatar_url}"/>
+ <a t-attf-href="#model=res.partner&id=#{record[0]}" t-att-title="record[1]"><t t-esc="record[1]"/></a>
+ <img t-if="record[2].is_editable" class="oe_edit_subtype hidden" t-att-src='_s + "/mail/static/src/img/icon-edit.gif"' title="Edit Subtype" t-att-data-id="record[0]"/>
+ <span t-if="widget.view_is_editable" class="oe_remove_follower oe_e" title="Remove this follower" t-att-data-id="record[0]">X</span>
</div>
<!--