From 1b9b26693ccc932c820df7cc1ccbe56dfc490fef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 2 Feb 2012 15:18:43 +0100 Subject: [PATCH] [ADD] Added first not-working draft for widget. Cleaned message search function. bzr revid: tde@openerp.com-20120202141843-4jq49mbd7a6ecq4b --- addons/mail/__openerp__.py | 16 +++- addons/mail/mail_message.py | 117 +++++++++++++++------------- addons/mail/static/src/js/mail.js | 53 +++++++------ addons/mail/static/src/xml/mail.xml | 17 ++++ 4 files changed, 126 insertions(+), 77 deletions(-) create mode 100644 addons/mail/static/src/xml/mail.xml diff --git a/addons/mail/__openerp__.py b/addons/mail/__openerp__.py index ed28c5be365..ec079463230 100644 --- a/addons/mail/__openerp__.py +++ b/addons/mail/__openerp__.py @@ -68,7 +68,19 @@ The main features are: 'installable': True, 'auto_install': False, 'certificate': '001056784984222247309', - 'images': ['images/customer_history.jpeg','images/messages_form.jpeg','images/messages_list.jpeg'], - 'css': ['static/src/css/mail_group.css'], + 'images': [ + 'images/customer_history.jpeg', + 'images/messages_form.jpeg', + 'images/messages_list.jpeg', + ], + 'css': [ + 'static/src/css/mail_group.css', + ], + 'js': [ + 'static/src/js/mail.js', + ], + 'qweb': [ + 'static/src/xml/mail.xml', + ], } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index dfd2fe00b92..b13d9a3d389 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -205,70 +205,81 @@ class mail_message(osv.osv): notification_obj.create(cr, uid, {'user_id': sub.user_id, 'message_id': msg_id}, context=context) return msg_id + def get_pushed_messages(self, cr, uid, context=None): + """Wall: get messages to display""" + notification_obj = self.pool.get('mail.notification') + notification_ids = notification_obj.search(cr, uid, [('user_id', '=', uid)], context=context) + notifications = notification_obj.browse(cr, uid, notification_ids, context=context) + + # TODO / REMARK: classify based on res_model / res_id to have a 1_level hierarchy ? + + return notifications + + #------------------------------------------------------ # Note specific api #------------------------------------------------------ - def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False): - if not context or not context.has_key('filter_search'): - return super(mail_message, self).search(cr, uid, args, offset=offset, limit=limit, order=order, context=context, count=count) + #def tmp_backup(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False): + #if not context or not context.has_key('filter_search'): + #return super(mail_message, self).search(cr, uid, args, offset=offset, limit=limit, order=order, context=context, count=count) - # get subscriptions - sub_obj = self.pool.get('mail.subscription') - sub_ids = sub_obj.search(cr, uid, [('user_id', '=', uid)]) - subs = sub_obj.browse(cr, uid, sub_ids) + ## get subscriptions + #sub_obj = self.pool.get('mail.subscription') + #sub_ids = sub_obj.search(cr, uid, [('user_id', '=', uid)]) + #subs = sub_obj.browse(cr, uid, sub_ids) - # stock tweets to find - res_model_ids_dict = {} - res_model_all_list = [] + ## stock tweets to find + #res_model_ids_dict = {} + #res_model_all_list = [] - # check all subscriptions - for sub in subs: - if sub.res_model and sub.res_id == 0 and sub.res_domain == False: - print "s-1" - if sub.res_model not in res_model_all_list: - res_model_all_list.append(sub.res_model) - elif sub.res_model and sub.res_id: - print "s-2" - if res_model_ids_dict.has_key(sub.res_model): - res_model_ids_dict[sub.res_model].append(sub.res_id) - else: - res_model_ids_dict[sub.res_model] = [sub.res_id] - elif sub.res_model and sub.res_domain: - print "s-3" - res_obj = self.pool.get(sub.res_model) - print sub.res_domain - #res_ids = res_obj.search(cr, uid, [('id', 'in', [1,2])]) - res_ids = res_obj.search(cr, uid, eval(sub.res_domain)) - if res_model_ids_dict.has_key(sub.res_model): - res_model_ids_dict[sub.res_model] += res_ids - else: - res_model_ids_dict[sub.res_model] = res_ids - print 'cacaprout' - else: - print 'erreur !!!' - print sub + ## check all subscriptions + #for sub in subs: + #if sub.res_model and sub.res_id == 0 and sub.res_domain == False: + #print "s-1" + #if sub.res_model not in res_model_all_list: + #res_model_all_list.append(sub.res_model) + #elif sub.res_model and sub.res_id: + #print "s-2" + #if res_model_ids_dict.has_key(sub.res_model): + #res_model_ids_dict[sub.res_model].append(sub.res_id) + #else: + #res_model_ids_dict[sub.res_model] = [sub.res_id] + #elif sub.res_model and sub.res_domain: + #print "s-3" + #res_obj = self.pool.get(sub.res_model) + #print sub.res_domain + ##res_ids = res_obj.search(cr, uid, [('id', 'in', [1,2])]) + #res_ids = res_obj.search(cr, uid, eval(sub.res_domain)) + #if res_model_ids_dict.has_key(sub.res_model): + #res_model_ids_dict[sub.res_model] += res_ids + #else: + #res_model_ids_dict[sub.res_model] = res_ids + #print 'cacaprout' + #else: + #print 'erreur !!!' + #print sub - # add fully-followed domains - args.append('|') - args.append(['model', 'in', res_model_all_list]) + ## add fully-followed domains + #args.append('|') + #args.append(['model', 'in', res_model_all_list]) - # add partially-followed domains - for x in range(0, len(res_model_ids_dict.keys())-1): - args.append('|') + ## add partially-followed domains + #for x in range(0, len(res_model_ids_dict.keys())-1): + #args.append('|') - for res_model in res_model_ids_dict.keys(): - if res_model not in res_model_all_list: - args.append('&') - args.append(['model', '=', res_model]) - args.append(['res_id', 'in', res_model_ids_dict[res_model]]) + #for res_model in res_model_ids_dict.keys(): + #if res_model not in res_model_all_list: + #args.append('&') + #args.append(['model', '=', res_model]) + #args.append(['res_id', 'in', res_model_ids_dict[res_model]]) - if context and context.has_key('filter_search'): - pass - else: - args = [] - print args - return super(mail_message, self).search(cr, uid, args, offset=offset, limit=limit,order=order, context=context, count=count) + #if context and context.has_key('filter_search'): + #pass + #else: + #args = [] + #print args + #return super(mail_message, self).search(cr, uid, args, offset=offset, limit=limit,order=order, context=context, count=count) #------------------------------------------------------ # E-Mail api diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index 2e81741f62a..6e23d813702 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -1,25 +1,34 @@ openerp.mail = function(session) { - -var mail = session.mail = {}; - -mail.Wall = session.web.Widget.extend({ - init: function(parent) { - }, - start: function() { - this.$element - }, -}); - -session.ThreadView - -session.MessgageInput - - - -var w = new session.mail.ThreadView(this); - -w.appendTo($("div.wall")); - - + + var mail = session.mail = {}; + + mail.Wall = session.web.Widget.extend({ + init: function(parent) { + }, + start: function() { +// this.$element + }, + }); + + mail.ThreadView = session.web.Widget.extend({ + template: 'MailTest', + + init: function(parent) { + }, + + start: function() { +// this.$element + }, + }); + + mail.MessgageInput = session.web.Widget.extend({ + }); + + + var tv = new mail.ThreadView(this); +// tv.appendTo($("div.wall")); +// tv.appendTo($("body")); + }; + // vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax: diff --git a/addons/mail/static/src/xml/mail.xml b/addons/mail/static/src/xml/mail.xml new file mode 100644 index 00000000000..005b4b23a79 --- /dev/null +++ b/addons/mail/static/src/xml/mail.xml @@ -0,0 +1,17 @@ + + \ No newline at end of file