[ADD] Added first not-working draft for widget. Cleaned message search function.

bzr revid: tde@openerp.com-20120202141843-4jq49mbd7a6ecq4b
This commit is contained in:
Thibault Delavallée 2012-02-02 15:18:43 +01:00
parent 109647a109
commit 1b9b26693c
4 changed files with 126 additions and 77 deletions

View File

@ -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:

View File

@ -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

View File

@ -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:

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<template>
<t t-name="MailTest">
<div style="height:100%;">
<p>Hello world !</p>
</div>
</t>
<!-- <t t-extend="ViewManagerAction">
<t t-jquery=".oe-shortcut-toggle" t-operation="after">
<a class="oe-share_link" href="#share_link" title="Follow">Follow</a>
<a class="oe-share" href="#share" title="Unfollow">Unfollow</a>
</t>
</t>-->
</template>