[IMP]Changed the position of methods and improved code.
bzr revid: psa@tinyerp.com-20130319073319-8myj2hx5iaqmi5xj
This commit is contained in:
+37
-34
@@ -140,40 +140,6 @@ class mail_thread(osv.AbstractModel):
|
||||
res[fol.res_id]['message_subtype_data'] = thread_subtype_dict
|
||||
return res
|
||||
|
||||
def edit_followers_subtype(self, cr, uid, ids, partner_id, context=None):
|
||||
res = dict((id, dict(message_subtype_data='')) for id in ids)
|
||||
|
||||
subtype_obj = self.pool.get('mail.message.subtype')
|
||||
subtype_ids = subtype_obj.search(cr, uid, ['|', ('res_model', '=', self._name), ('res_model', '=', False)], context=context)
|
||||
subtype_dict = dict((subtype.name, dict(default=subtype.default, followed=False, id=subtype.id)) for subtype in subtype_obj.browse(cr, uid, subtype_ids, context=context))
|
||||
for id in ids:
|
||||
res[id]['message_subtype_data'] = subtype_dict.copy()
|
||||
|
||||
fol_obj = self.pool.get('mail.followers')
|
||||
fol_ids = fol_obj.search(cr, uid, [
|
||||
('partner_id', '=', partner_id),
|
||||
('res_id', 'in', ids),
|
||||
('res_model', '=', self._name),
|
||||
], context=context)
|
||||
for fol in fol_obj.browse(cr, uid, fol_ids, context=context):
|
||||
thread_subtype_dict = res[fol.res_id]['message_subtype_data']
|
||||
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 apply_edited_subtypes(self, cr, uid, ids, partner_id, check_list, context=None):
|
||||
""" Apply the edited subtypes
|
||||
of the user."""
|
||||
fol_obj = self.pool.get('mail.followers')
|
||||
fol_ids = fol_obj.search(cr, uid, [
|
||||
('partner_id', '=', partner_id),
|
||||
('res_id', 'in', ids),
|
||||
('res_model', '=', self._name),
|
||||
], context=context)
|
||||
fol_obj.write(cr, uid, fol_ids, {'subtype_ids': [(6,0, check_list)]}, context=context)
|
||||
return True
|
||||
|
||||
def _search_message_unread(self, cr, uid, obj=None, name=None, domain=None, context=None):
|
||||
return [('message_ids.to_read', '=', True)]
|
||||
|
||||
@@ -323,6 +289,43 @@ class mail_thread(osv.AbstractModel):
|
||||
default['message_follower_ids'] = []
|
||||
return super(mail_thread, self).copy(cr, uid, id, default=default, context=context)
|
||||
|
||||
#------------------------------------------------------
|
||||
# Edit and apply followers subtypes.
|
||||
#------------------------------------------------------
|
||||
def edit_followers_subtype(self, cr, uid, ids, partner_id, context=None):
|
||||
res = dict((id, dict(message_subtype_data='')) for id in ids)
|
||||
|
||||
subtype_obj = self.pool.get('mail.message.subtype')
|
||||
subtype_ids = subtype_obj.search(cr, uid, ['|', ('res_model', '=', self._name), ('res_model', '=', False)], context=context)
|
||||
subtype_dict = dict((subtype.name, dict(default=subtype.default, followed=False, id=subtype.id)) for subtype in subtype_obj.browse(cr, uid, subtype_ids, context=context))
|
||||
for id in ids:
|
||||
res[id]['message_subtype_data'] = subtype_dict.copy()
|
||||
|
||||
fol_obj = self.pool.get('mail.followers')
|
||||
fol_ids = fol_obj.search(cr, uid, [
|
||||
('partner_id', '=', partner_id),
|
||||
('res_id', 'in', ids),
|
||||
('res_model', '=', self._name),
|
||||
], context=context)
|
||||
for fol in fol_obj.browse(cr, uid, fol_ids, context=context):
|
||||
thread_subtype_dict = res[fol.res_id]['message_subtype_data']
|
||||
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 apply_edited_subtypes(self, cr, uid, ids, partner_id, check_list, context=None):
|
||||
""" Apply the edited subtypes
|
||||
of the user."""
|
||||
fol_obj = self.pool.get('mail.followers')
|
||||
fol_ids = fol_obj.search(cr, uid, [
|
||||
('partner_id', '=', partner_id),
|
||||
('res_id', 'in', ids),
|
||||
('res_model', '=', self._name),
|
||||
], context=context)
|
||||
fol_obj.write(cr, uid, fol_ids, {'subtype_ids': [(6,0, check_list)]}, context=context)
|
||||
return True
|
||||
|
||||
#------------------------------------------------------
|
||||
# Automatically log tracked fields
|
||||
#------------------------------------------------------
|
||||
|
||||
@@ -92,9 +92,9 @@ openerp_mail_followers = function(session, mail) {
|
||||
buttons: [
|
||||
{ text: _t("Apply"), click: function() {
|
||||
self.on_apply_subtype(id, partner_id);
|
||||
$dialog.remove();
|
||||
$(this).remove();
|
||||
}},
|
||||
{ text: _t("Cancel"), click: function() { $dialog.remove(); }}
|
||||
{ text: _t("Cancel"), click: function() { $(this).remove(); }}
|
||||
],
|
||||
});
|
||||
this.ds_model.call('edit_followers_subtype', [[id], partner_id, new session.web.CompoundContext(this.build_context(), {})])
|
||||
|
||||
@@ -48,6 +48,10 @@
|
||||
</table>
|
||||
</t>
|
||||
|
||||
<!--
|
||||
followers.edit.subtype template
|
||||
Template used to edit the display message subtypes of a follower subscription
|
||||
-->
|
||||
<t t-name="mail.followers.edit.subtype">
|
||||
<table class='oe_subtype'>
|
||||
<tr>
|
||||
|
||||
Reference in New Issue
Block a user