From 5561797ce8cb17643607ab8b57e233b22acf7101 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 8 Feb 2012 18:08:08 +0100 Subject: [PATCH] [IMP] Basic Wall system displaying all pushes messages. bzr revid: tde@openerp.com-20120208170808-8bac1bnj53z4650u --- addons/mail/mail_message.py | 8 ++++-- addons/mail/static/src/js/mail.js | 39 ++++++++++++++++++++++++++++- addons/mail/static/src/xml/mail.xml | 6 +++++ 3 files changed, 50 insertions(+), 3 deletions(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 6543dc63463..2ecdad5ceca 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -222,9 +222,13 @@ class mail_message(osv.osv): 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 ? + msg_ids = [notification.message_id.id for notification in notifications] + msgs = self.read(cr, uid, msg_ids, context=context) + print msgs - return notifications + # TODO / REMARK: classify based on res_model / res_id to have a 1_level hierarchy ? + + return msgs #------------------------------------------------------ # E-Mail api diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index 184f4fbada5..bd82399b88e 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -97,7 +97,44 @@ openerp.mail = function(session) { init: function() { this._super.apply(this, arguments); - alert('Cacaboudin !!'); + /* DataSets */ + this.ds_msg = new session.web.DataSet(this, 'mail.message'); + }, + + start: function() { + var self = this; + this._super.apply(this, arguments); + self.$element.find('button.oe_mail_action_comment').bind('click', function () { self.do_comment(); }); + this.ds_msg.call('get_pushed_messages', []).then( + this.proxy('display_records')); + }, + + stop: function () { + this._super(); + }, + + fetch_messages: function () { + return this.ds_msg.call('get_pushed_messages', []).then( + this.proxy('display_records')); + }, + + display_records: function (records) { + this.$element.find('div.oe_mail_comments').empty(); + var self = this; + _(records).each(function (record) { + var template = 'ThreadMsgView'; + var render_res = session.web.qweb.render(template, { + 'record': record, + }); + $('
').html(render_res).appendTo(self.$element.find('div.oe_mail_comments')); + }); +// this.timeout = setTimeout(this.proxy('fetch_messages'), 5000); + }, + + do_comment: function () { + var body_text = this.$element.find('textarea').val(); + return this.ds.call('message_append_note', [[this.view.datarecord.id], 'Reply comment', body_text, type='comment']).then( + this.proxy('fetch_messages')); }, }); }; diff --git a/addons/mail/static/src/xml/mail.xml b/addons/mail/static/src/xml/mail.xml index e9895ce4c7b..58e242829b6 100644 --- a/addons/mail/static/src/xml/mail.xml +++ b/addons/mail/static/src/xml/mail.xml @@ -37,6 +37,12 @@
+
+
+ +
+
+
\ No newline at end of file