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