[IMP] 1) Added code for opening the dialog box of edit followers,
2) Added an image in the mail.message.subtype template which is visible when the Technical Features menu is selected true . 3) On clicking on the edit pencil which is with the followers name gives the subtypes of the specific followers on which the user had clicked rather than the current form. bzr revid: psa@tinyerp.com-20130314102949-4v9l6xpz5u1jeq10
This commit is contained in:
parent
b1ae53e40e
commit
0b62a6858f
|
@ -22,7 +22,6 @@
|
|||
from openerp.osv import osv
|
||||
from openerp.osv import fields
|
||||
|
||||
|
||||
class mail_message_subtype(osv.osv):
|
||||
""" Class holding subtype definition for messages. Subtypes allow to tune
|
||||
the follower subscription, allowing only some subtypes to be pushed
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
<record model="ir.ui.view" id="view_message_subtype_tree">
|
||||
<field name="name">mail.message.subtype.tree</field>
|
||||
<field name="model">mail.message.subtype</field>
|
||||
<field name="priority">10</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Subtype">
|
||||
<field name="name"/>
|
||||
|
@ -33,25 +34,11 @@
|
|||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record model="ir.ui.view" id="view_edit_message_subtype_tree">
|
||||
<field name="name">edit.message.subtype.tree</field>
|
||||
<field name="model">mail.message.subtype</field>
|
||||
<field name="priority">10</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Edit Subtype" editable="top">
|
||||
<field name="name"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record model="ir.actions.act_window" id="action_view_message_subtype">
|
||||
<field name="name">Subtypes</field>
|
||||
<field name="res_model">mail.message.subtype</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="view_message_subtype_tree"/>
|
||||
</record>
|
||||
<menuitem name="Subtypes" id="menu_message_subtype" parent="base.menu_email" action="action_view_message_subtype"/>
|
||||
|
||||
|
|
|
@ -138,9 +138,56 @@ 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 edit_followers_subtype(self, cr, uid, ids, partner_id, context=None):
|
||||
print "cr, uid, ids, partner_id, co",cr, uid, ids, partner_id
|
||||
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)
|
||||
print "\n\n fol _ids>>>>>>>>>>", fol_ids
|
||||
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
|
||||
print "\n<<<<res partner>>>>",res
|
||||
return res
|
||||
|
||||
def apply_subtype(self, cr, uid, ids, partner_id, context=None):
|
||||
print "\n\n uid, ids, subtype_id,", uid, ids, partner_id
|
||||
res=[]
|
||||
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)
|
||||
print "\n\n fol _ids>>>>>>>>>>", fol_ids
|
||||
for fol in fol_obj.browse(cr, uid, fol_ids, context=context):
|
||||
print "\fol.subtype::::>:>:>:>:>", fol.subtype_ids
|
||||
for subtype in fol.subtype_ids:
|
||||
res.append(subtype.id)
|
||||
print "\nres::::>:>:>:>:>", res
|
||||
if partner_id==True:
|
||||
res.append(ids[0])
|
||||
else:
|
||||
res.remove(ids[0])
|
||||
fol_obj.write(cr, uid, fol_ids, {'subtype_ids': [(6,0,res)]}, context=context)
|
||||
print "\nsubtype_id......>>>", partner_id, res
|
||||
return partner_id
|
||||
|
||||
|
||||
def _search_message_unread(self, cr, uid, obj=None, name=None, domain=None, context=None):
|
||||
return [('message_ids.to_read', '=', True)]
|
||||
|
||||
|
|
|
@ -80,21 +80,71 @@ openerp_mail_followers = function(session, mail) {
|
|||
this.$el.on('click', '.oe_show_more', self.on_show_more_followers)
|
||||
},
|
||||
|
||||
on_edit_subtype: function() {
|
||||
on_edit_subtype: function(event) {
|
||||
var self = this;
|
||||
var records = [];
|
||||
var partner_id = $(event.target).data('id');
|
||||
var id = this.view.datarecord.id;
|
||||
var res_model = this.view.dataset.model;
|
||||
console.log('thissssssssssssssss>>', this, id, partner_id);
|
||||
var $dialog = session.web.dialog($('<div>'), {
|
||||
modal: true,
|
||||
title: partner_id,
|
||||
buttons: [
|
||||
{text: _t("Apply"), click: function() {
|
||||
// self.apply_subtype(id, partner_id);
|
||||
$(this).dialog("close");
|
||||
}
|
||||
},
|
||||
{text: _t("Cancel"), click: function() { $(this).dialog("close"); }}
|
||||
],
|
||||
});
|
||||
this.ds_model.call('edit_followers_subtype', [[id], [partner_id], new session.web.CompoundContext(this.build_context(), {})])
|
||||
.then(function (data) {
|
||||
// console.log('then>>>>>', data, id, partner_id);
|
||||
if (data[id]) {
|
||||
records = data[id].message_subtype_data;
|
||||
// console.log('records........', records);
|
||||
}
|
||||
_(records).each(function (record, record_name) {
|
||||
record.name = record_name;
|
||||
record.followed = record.followed || undefined;
|
||||
console.log('record??????????????', record);
|
||||
$(session.web.qweb.render("mail.followers.subtype", {'record': record})).appendTo($dialog);
|
||||
});
|
||||
});
|
||||
|
||||
/* var partner_id = $(event.target).data('id');
|
||||
var context = new session.web.CompoundContext(this.build_context(), {});
|
||||
|
||||
var action = {
|
||||
type: 'ir.actions.act_window',
|
||||
res_model: 'mail.message.subtype',
|
||||
res_model: 'mail.message.subtype', //'subtype.edit.wizard',
|
||||
domain: [['res_model','=', self.view.model]],
|
||||
view_mode: 'list',
|
||||
view_type: 'list',
|
||||
views: [[false, 'list']],
|
||||
target: 'new',
|
||||
context: {
|
||||
'res_model': this.view.dataset.model,
|
||||
'res_id': this.view.datarecord.id,
|
||||
'partner_id': partner_id,
|
||||
},
|
||||
}
|
||||
|
||||
this.do_action(action, {
|
||||
on_close: function() {
|
||||
self.read_value();
|
||||
},
|
||||
});*/
|
||||
|
||||
},
|
||||
|
||||
apply_subtype: function(id, partner_id) {
|
||||
console.log('id>>>partner_id>>> ', id, partner_id);
|
||||
this.ds_model.call('apply_subtype', [[id], [partner_id], new session.web.CompoundContext(this.build_context(), {})])
|
||||
.then(function (data) {
|
||||
console.log('dataaaaaaaaaaaaa', data);
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -154,7 +204,7 @@ openerp_mail_followers = function(session, mail) {
|
|||
.then(this.proxy('check_group_tech_feature'));
|
||||
},
|
||||
|
||||
check_group_tech_feature: function(){
|
||||
check_group_tech_feature: function() {
|
||||
var self = this;
|
||||
var edit_subtypes = new session.web.Model("res.groups");
|
||||
edit_subtypes.query(["name","users"])
|
||||
|
@ -276,6 +326,7 @@ openerp_mail_followers = function(session, mail) {
|
|||
.then(this.proxy('read_value'));
|
||||
|
||||
_.each(this.$('.oe_subtype_list input'), function (record) {
|
||||
console.log('do follow>', record);
|
||||
$(record).attr('checked', 'checked');
|
||||
});
|
||||
},
|
||||
|
|
|
@ -32,7 +32,8 @@
|
|||
<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 t-raw="record.name"/></a>
|
||||
<img t-if="widget.check_access" class="oe_edit_subtype" t-att-src='_s + "/mail/static/src/img/icon-edit.gif"' title="Edit Subtype" t-att-data-id="record.id"/>
|
||||
<!--t t-js="ab">console.log(':::::::::::;', ab);</t-->
|
||||
<img class="oe_edit_subtype" 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>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in New Issue