Sanjay Gohel (Open ERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-message-sub-type-apa-add-checkbox-sgo
into lp:~openerp-dev/openobject-addons/trunk-message-sub-type-apa.
Requested reviews:
Amit Patel (OpenERP) (apa-tiny)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-message-sub-type-apa-add-checkbox-sgo/+merge/120964
hello sir,
I have made following changes.
1) Add checkbox on click of follow and beside subtype name.
2) on checked of checkbox write subtype_ids in mail follower model. show only
checked record on feeds
3) unchecked of icons it removes from subtype_ids
Thank You.
Sanjay Gohel(sgo)
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-message-sub-type-apa-add-checkbox-sgo/+merge/120964
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/trunk-message-sub-type-apa.
=== modified file 'mail/mail_thread.py'
--- mail/mail_thread.py 2012-08-16 11:03:06 +0000
+++ mail/mail_thread.py 2012-08-23 11:00:43 +0000
@@ -1192,10 +1192,10 @@
""" Set as read. """
return self.write(cr, uid, ids, {'message_state': True}, context=context)
- def message_subscribe_udpate_subtypes(self, cr, uid, ids, user_id, subtype_ids):
+ def message_subscribe_udpate_subtypes(self, cr, uid, ids, user_id, subtype_ids,context=None):
subscription_obj = self.pool.get('mail.followers')
- subscription_ids = subscription_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids)])
- return subscription_obj.write(cr, uid, subscription_ids, {'subtype_ids': [6, 0 , subtype_ids]}, context = context) #overright or add new one
+ subscription_ids = subscription_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids),('user_id','=',user_id)])
+ return subscription_obj.write(cr, uid, subscription_ids, {'subtype_ids': [(6, 0 , subtype_ids)]}, context = context) #overright or add new one
def message_subscription_remove_subtype(self, cr, uid, ids, user_id, subtype_id):
subscription_obj = self.pool.get('mail.followers')
=== modified file 'mail/static/src/js/mail_followers.js'
--- mail/static/src/js/mail_followers.js 2012-08-15 23:28:25 +0000
+++ mail/static/src/js/mail_followers.js 2012-08-23 11:00:43 +0000
@@ -31,7 +31,9 @@
this.params.display_control = this.node.attrs.display_control || false;
this.params.display_actions = this.node.attrs.display_actions || false;
this.ds_model = new session.web.DataSetSearch(this, this.view.model);
+ 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')
},
start: function() {
@@ -40,10 +42,24 @@
// any other method to know if the view is in create mode anymore
this.view.on("change:actual_mode", this, this._check_visibility);
this._check_visibility();
+ this.fetch_subtype();
+ this.$element.find('ul.oe_mail_recthread_subtype').click(function () {
+ var subtypelist = new Array();
+ _($(this).find('.oe_msg_subtype_check')).each(function (record){
+ if($(record).is(':checked')) {
+ subtypelist.push(parseInt($(record).attr('id')))}
+ });
+ self.ds_model.call('message_subscribe_udpate_subtypes',[[self.view.datarecord.id],self.session.uid,subtypelist])
+ })
this.$element.find('button.oe_mail_button_followers').click(function () { self.do_toggle_followers(); });
if (! this.params.display_control) {
- this.$element.find('button.oe_mail_button_followers').hide(); }
- this.$element.find('button.oe_mail_button_follow').click(function () { self.do_follow(); })
+ this.$element.find('button.oe_mail_button_followers').hide();
+ this.$element.find('ul.oe_mail_recthread_subtype').hide()
+ }
+ this.$element.find('button.oe_mail_button_follow').click(function () {
+ self.do_follow();
+ self.fetch_subtype();
+ })
.mouseover(function () { $(this).html('Follow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); })
.mouseleave(function () { $(this).html('Not following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); });
this.$element.find('button.oe_mail_button_unfollow').click(function () { self.do_unfollow(); })
@@ -54,6 +70,7 @@
_check_visibility: function() {
this.$element.toggle(this.view.get("actual_mode") !== "create");
+ if(this.view.get("actual_mode") == "create"){this.fetch_subtype();}
},
destroy: function () {
@@ -67,6 +84,7 @@
this.$element.find('button.oe_mail_button_followers').html('Hide followers')
this.$element.find('button.oe_mail_button_follow').hide();
this.$element.find('button.oe_mail_button_unfollow').hide();
+ this.$element.find('ul.oe_mail_recthread_subtype').hide()
},
set_value: function(value_) {
@@ -98,15 +116,49 @@
});
if (this.is_subscriber) {
this.$element.find('button.oe_mail_button_follow').hide();
- this.$element.find('button.oe_mail_button_unfollow').show(); }
+ this.$element.find('button.oe_mail_button_unfollow').show();
+ this.$element.find('ul.oe_mail_recthread_subtype').show(); }
else {
this.$element.find('button.oe_mail_button_follow').show();
- this.$element.find('button.oe_mail_button_unfollow').hide(); }
- },
-
+ this.$element.find('button.oe_mail_button_unfollow').hide();
+ this.$element.find('ul.oe_mail_recthread_subtype').hide() }
+ },
+
+ // Display the subtypes of each records.
+ display_subtype: function(records) {
+ var self = this
+ var subtype_list = this.$element.find('ul.oe_mail_recthread_subtype').empty();
+ var follower_ids = this.follower_model.call('search',[[['res_model','=',this.ds_model.model],['res_id','=',this.view.datarecord.id],['user_id','=',this.session.uid]]])
+ follower_ids.then(function (record){
+ var follower_read = self.follower_model.call('read', [record,['subtype_ids']]);
+ follower_read.then(function (follower_record){
+ if(follower_record.length != 0){
+ _(follower_record[0].subtype_ids).each(function (subtype_id){
+ self.$element.find('.oe_msg_subtype_check[id=' + subtype_id + ']')[0].checked=true
+ });
+ }
+ })
+ });
+ _(records).each(function (record) {
+ record.name = record.name.toLowerCase().replace(/\b[a-z]/g, function(letter) {
+ return letter.toUpperCase();
+ });
+ $(session.web.qweb.render('mail.record_thread.subtype', {'record': record})).appendTo(subtype_list);
+ });
+ },
+
do_follow: function () {
return this.ds_model.call('message_subscribe', [[this.view.datarecord.id]]).pipe(this.proxy('set_value'));
},
+
+ //fetch subtype from subtype model
+ fetch_subtype: function () {
+ var self = this
+ var subtype_object = this.sub_model.call('search', [[['model_ids.model','=',this.view.model]]]);
+ subtype_object.then(function (subtype_ids){
+ self.sub_model.call('read', [subtype_ids || self.get_value(),['name', 'default']]).then(self.proxy('display_subtype'));
+ });
+ },
do_unfollow: function () {
return this.ds_model.call('message_unsubscribe', [[this.view.datarecord.id]]).pipe(this.proxy('set_value'));
=== modified file 'mail/static/src/xml/mail_followers.xml'
--- mail/static/src/xml/mail_followers.xml 2012-08-15 23:26:49 +0000
+++ mail/static/src/xml/mail_followers.xml 2012-08-23 11:00:43 +0000
@@ -3,7 +3,7 @@
<!--
followers main template
- Template used to display the followers and the actions in a record.
+ Template used to display the followers, the actions and the subtypes in a record.
-->
<div t-name="mail.followers" class="oe_mail_recthread_aside">
<div class="oe_mail_recthread_actions">
@@ -16,6 +16,7 @@
<h4><t t-raw="widget.params.title"/></h4>
</t>
<ul class="oe_mail_followers_display"></ul>
+ <ul class="oe_mail_recthread_subtype"></ul>
</div>
</div>
@@ -26,6 +27,23 @@
<li t-name="mail.followers.partner">
<img class="oe_mail_thumbnail oe_mail_frame" t-attf-src="{record.avatar_url}"/>
<a t-attf-href="#model=res.users&id=#{record.id}"><t t-raw="record.name"/></a>
+ </li>\
+
+ <!--
+ record_thread.subtype template
+ Template used to display subtype of record
+ -->
+ <li t-name="mail.record_thread.subtype">
+ <table width="50%">
+ <tr>
+ <td>
+ <a t-attf-href="#model=mail.message.subtype&id=#{record.id}"><t t-raw="record.name"/></a>
+ </td>
+ <td width="10%">
+ <input type="checkbox" t-att-id="record.id" t-att-name="record.name" class="oe_msg_subtype_check"/>
+ </td>
+ </tr>
+ </table>
</li>
</template>
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp