From b5df63291a0de2cbcd42a348db5ffa925f8e4efc Mon Sep 17 00:00:00 2001 From: Paramjit Singh Sahota Date: Fri, 15 Mar 2013 18:01:57 +0530 Subject: [PATCH] [IMP] Removed the dialog box on apply and close to open a new dialog box everytime. Removed unwanted code. bzr revid: psa@tinyerp.com-20130315123157-n0n3fdej014ysz7v --- addons/mail/mail_message_subtype.py | 1 + addons/mail/mail_thread.py | 6 ++-- addons/mail/static/src/js/mail_followers.js | 37 +++++++-------------- 3 files changed, 17 insertions(+), 27 deletions(-) diff --git a/addons/mail/mail_message_subtype.py b/addons/mail/mail_message_subtype.py index 253ec600c6c..bef6e427c3b 100644 --- a/addons/mail/mail_message_subtype.py +++ b/addons/mail/mail_message_subtype.py @@ -22,6 +22,7 @@ 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 diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index d85e91fa8ba..ab4eead1a6e 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -162,7 +162,8 @@ class mail_thread(osv.AbstractModel): 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): + def apply_edited_subtypes(self, cr, uid, ids, partner_id, check_list, context=None): + print "\n\n uid, ids, partner_id, check_list,,>", uid, ids, partner_id, check_list, """ Apply the edited subtypes of the user.""" fol_obj = self.pool.get('mail.followers') @@ -171,7 +172,8 @@ class mail_thread(osv.AbstractModel): ('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) + print "\n fol _ids>", fol_ids, check_list + 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): diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 0eb864d02da..0bfcbfc29e9 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -31,7 +31,6 @@ openerp_mail_followers = function(session, mail) { this.ds_model = new session.web.DataSetSearch(this, this.view.model); this.ds_follow = new session.web.DataSetSearch(this, this.field.relation); this.ds_users = new session.web.DataSetSearch(this, 'res.users'); - this.check_access = false; this.value = []; this.followers = []; @@ -87,15 +86,15 @@ openerp_mail_followers = function(session, mail) { var partner_name = $(event.target).siblings('a').text(); var id = this.view.datarecord.id; var res_model = this.view.dataset.model; - var $dialog = session.web.dialog($('
'), { + var $dialog = new session.web.dialog($('
'), { modal: true, title: _t('Edit Subtypes of ') + '"' + partner_name + '"', buttons: [ { text: _t("Apply"), click: function() { self.on_apply_subtype(id, partner_id); - $(this).dialog("close"); + $dialog.remove(); }}, - { text: _t("Cancel"), click: function() { $(this).dialog("close"); }} + { text: _t("Cancel"), click: function() { $dialog.remove(); }} ], }); this.ds_model.call('edit_followers_subtype', [[id], partner_id, new session.web.CompoundContext(this.build_context(), {})]) @@ -112,16 +111,17 @@ openerp_mail_followers = function(session, mail) { }, on_apply_subtype: function(id, partner_id) { - var checklist = new Array(); - _($('.oe_edit_actions input[type="checkbox"]')).each(function (record) { - if ($(record).is(':checked')) { - checklist.push(parseInt($(record).data('id'))); - } + var check_list = new Array(); + _($('.oe_edit_actions input[type="checkbox"]')).each(function (records) { + if ($(records).is(':checked')) { + check_list.push(parseInt($(records).data('id'))); + } }); - if (!checklist.length) { + + if (!check_list.length) { this.do_unfollow(); } else { - this.ds_model.call('apply_edited_subtypes', [[id], partner_id, checklist, new session.web.CompoundContext(this.build_context(), {})]) + return this.ds_model.call('apply_edited_subtypes', [[id], partner_id, check_list, new session.web.CompoundContext(this.build_context(), {})]) .then(this.proxy('read_value')); } }, @@ -178,20 +178,7 @@ openerp_mail_followers = function(session, mail) { return this.ds_follow.call('read', [this.value, ['name', 'user_ids']]) .then(this.proxy('display_followers'), this.proxy('fetch_generic')) .then(this.proxy('display_buttons')) - .then(this.proxy('fetch_subtypes')) - .then(this.proxy('check_group_tech_feature')); - }, - - check_group_tech_feature: function() { - var self = this; - var edit_subtypes = new session.web.Model("res.groups"); - edit_subtypes.query(["name","users"]) - .filter([["name","=","Technical Features"], ["users","in",self.session.uid]]).first() - .then(function(res) { - if (res) { - self.check_access = true; - } - }); + .then(this.proxy('fetch_subtypes')); }, /** Read on res.partner failed: fall back on a generic case