[ADD] Added firsdt draft of ThreadView widget
bzr revid: tde@openerp.com-20120206090618-s3m5lpdkz7zh1sh2
This commit is contained in:
@@ -110,7 +110,8 @@
|
||||
string="Unfollow" icon="gtk-go-forward" colspan="2"/>
|
||||
</group>
|
||||
<separator string="Messages" colspan="4"/>
|
||||
<field name="message_ids_tmp"/>
|
||||
<field name="message_ids_tmp" colspan="4"/>
|
||||
<field name="thread_view" widget="ThreadView"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -36,27 +36,25 @@ class mail_subscription(osv.osv):
|
||||
_name = 'mail.subscription'
|
||||
_rec_name = 'id'
|
||||
_columns = {
|
||||
'res_model': fields.char('Related Document model', size=128, select=1),
|
||||
'res_model': fields.char('Related Document Model', size=128, select=1, required=True),
|
||||
'res_id': fields.integer('Related Document ID', select=1),
|
||||
#'res_domain': fields.char('res_domain', size=256),
|
||||
'user_id': fields.integer('Related User ID', select=1),
|
||||
'user_id': fields.integer('Related User ID', select=1, required=True),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
}
|
||||
|
||||
mail_subscription()
|
||||
|
||||
class mail_notification(osv.osv):
|
||||
"""
|
||||
TODO
|
||||
"""
|
||||
|
||||
_name = 'mail.notification'
|
||||
_rec_name = 'id'
|
||||
_log_access = False
|
||||
_columns = {
|
||||
'user_id': fields.many2one('res.users', string='User',
|
||||
ondelete='cascade', required=True),
|
||||
ondelete='cascade', required=True, select=1),
|
||||
'message_id': fields.many2one('mail.message', string='Message',
|
||||
ondelete='cascade', required=True),
|
||||
'read': fields.boolean('Read'),
|
||||
|
||||
@@ -58,7 +58,7 @@ class mail_thread(osv.osv):
|
||||
res = {}
|
||||
for thread in self.browse(cr, uid, ids, context=context):
|
||||
records = self.message_load(cr, uid, [thread.id], context=context)
|
||||
res[thread.id] = [obj.id for obj in records]
|
||||
res[thread.id] = [obj['id'] for obj in records]
|
||||
return res
|
||||
|
||||
# TODO remove this and copy method, this will be replaced by message_load
|
||||
@@ -255,8 +255,14 @@ class mail_thread(osv.osv):
|
||||
msg_obj = self.pool.get('mail.message')
|
||||
msg_ids = []
|
||||
for id in ids:
|
||||
print id
|
||||
print self._name
|
||||
print context
|
||||
msg_ids += msg_obj.search(cr, uid, ['&', ('res_id', '=', id), ('model', '=', self._name)], context=context)
|
||||
msgs = msg_obj.browse(cr, uid, msg_ids)
|
||||
print msg_ids
|
||||
#msgs = msg_obj.browse(cr, uid, msg_ids)
|
||||
msgs = msg_obj.read(cr, uid, msg_ids, context=context)
|
||||
print msgs
|
||||
return msgs
|
||||
|
||||
#------------------------------------------------------
|
||||
|
||||
@@ -2,34 +2,47 @@ openerp.mail = function(session) {
|
||||
|
||||
var mail = session.mail = {};
|
||||
|
||||
mail.Wall = session.web.Widget.extend({
|
||||
init: function(parent) {
|
||||
},
|
||||
start: function() {
|
||||
// this.$element
|
||||
},
|
||||
});
|
||||
|
||||
mail.ThreadView = session.web.Widget.extend({
|
||||
session.web.form.widgets.add(
|
||||
'ThreadView', 'openerp.mail.ThreadView');
|
||||
|
||||
/* ThreadView Widget: thread of comments */
|
||||
mail.ThreadView = session.web.form.Field.extend({
|
||||
// QWeb template to use when rendering the object
|
||||
template: 'MailTest',
|
||||
// autogenerated id prefix, specificity helps when debugging
|
||||
// identifier_prefix: 'my-id-prefix-',
|
||||
|
||||
init: function(parent) {
|
||||
this._super(parent);
|
||||
}
|
||||
|
||||
start: function() {
|
||||
// this.$element
|
||||
init: function() {
|
||||
this.timeout;
|
||||
this._super.apply(this, arguments);
|
||||
this.ds = new session.web.DataSet(this, this.view.model);
|
||||
},
|
||||
stop: function () {
|
||||
clearTimeout(this.timeout);
|
||||
this._super();
|
||||
},
|
||||
|
||||
set_value: function() {
|
||||
this._super.apply(this, arguments);
|
||||
if (! this.view.datarecord.id) { return; }
|
||||
return this.fetch_messages();
|
||||
},
|
||||
|
||||
fetch_messages: function () {
|
||||
return this.ds.call('message_load', [[this.view.datarecord.id]]).then(
|
||||
this.proxy('display_records'));
|
||||
},
|
||||
|
||||
display_records: function (records) {
|
||||
// this.$element.empty();
|
||||
var self = this;
|
||||
_(records).each(function (record) {
|
||||
$('<div>').text(record.body_text).appendTo(self.$element);
|
||||
});
|
||||
this.timeout = setTimeout(this.proxy('fetch_messages'), 5000);
|
||||
}
|
||||
});
|
||||
|
||||
mail.MessgageInput = session.web.Widget.extend({
|
||||
});
|
||||
|
||||
|
||||
// var tv = new mail.ThreadView(this);
|
||||
// tv.appendTo($("td.oe_form_field_mail.ThreadView"));
|
||||
// tv.appendTo($("body"));
|
||||
|
||||
};
|
||||
|
||||
// vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax:
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<template>
|
||||
|
||||
<t t-name="MailTest">
|
||||
<div style="height:100%;">
|
||||
<p>Hello world !</p>
|
||||
</div>
|
||||
</t>
|
||||
<div t-name="MailTest">
|
||||
vdvgfxdfxdfv
|
||||
</div>
|
||||
|
||||
<!-- <t t-extend="ViewManagerAction">
|
||||
<t t-jquery=".oe-shortcut-toggle" t-operation="after">
|
||||
|
||||
Reference in New Issue
Block a user