[IMP] Added need_action_user_id, as draft for mechanism to know wich user must take an action; small fixes in views; updated ThreadView widget: first draft for follow/unfollow buttons

bzr revid: tde@openerp.com-20120206112623-fvwjf7o0iuwi3ocs
This commit is contained in:
Thibault Delavallée
2012-02-06 12:26:23 +01:00
parent 150aeed534
commit a61be0bf53
7 changed files with 48 additions and 18 deletions
+2 -3
View File
@@ -109,9 +109,8 @@
<button name="action_unfollow" type="object" context="{}"
string="Unfollow" icon="gtk-go-forward" colspan="2"/>
</group>
<separator string="Messages" colspan="4"/>
<field name="message_ids_tmp" colspan="4"/>
<field name="thread_view" widget="ThreadView"/>
<separator string="OpenChatter" colspan="4"/>
<field name="message_ids_social" colspan="4" widget="ThreadView" nolabel="1"/>
</form>
</field>
</record>
+2
View File
@@ -183,6 +183,7 @@ class mail_message(osv.osv):
('notification', 'Notification'),
], 'Type', help="Message type: e-mail for e-mail message, notification for system message, comment for other messages such as user replies"),
'need_action': fields.boolean('Need action', help="Asks the user to perform an action"),
'need_action_user_id': fields.many2one('res.users', 'Action user', help="User requested to perform an action"),
}
_defaults = {
@@ -195,6 +196,7 @@ class mail_message(osv.osv):
#------------------------------------------------------
def create(self, cr, uid, vals, context=None):
print vals
msg_id = super(mail_message, self).create(cr, uid, vals, context)
# push the message to suscribed users
subscription_obj = self.pool.get('mail.subscription')
+2 -4
View File
@@ -32,11 +32,11 @@ class mail_subscription(osv.osv):
- res_id: ID of resource OR
- res_domain: a domain filtering followed objects - currently removed
"""
_name = 'mail.subscription'
_rec_name = 'id'
_columns = {
'res_model': fields.char('Related Document Model', size=128, select=1, required=True),
'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, required=True),
@@ -60,9 +60,7 @@ class mail_notification(osv.osv):
'read': fields.boolean('Read'),
# TODO: add a timestamp ? or use message date ?
}
_defaults = {
'read': False,
}
mail_notification()
+3 -3
View File
@@ -64,9 +64,9 @@ class mail_thread(osv.osv):
# TODO remove this and copy method, this will be replaced by message_load
_columns = {
'message_ids': fields.one2many('mail.message', 'res_id', 'Messages', readonly=True),
'message_ids_tmp': fields.function(_get_message_ids, method=True,
type='one2many', obj='mail.message', string='Temp messages'),
'thread_view': fields.char('ThreadView', size=64, widget='mail.ThreadView'),
'message_ids_social': fields.function(_get_message_ids, method=True,
type='one2many', obj='mail.message', string='Temp messages',
widget='mail.ThreadView'),
}
#------------------------------------------------------
+1 -1
View File
@@ -12,8 +12,8 @@
<tree string="Communication History">
<field name="display_text"/>
</tree>
<field name="thread_view" colspan="4"/>
</field>
<field name="message_ids_social" colspan="4" widget="ThreadView"/>
</form>
</field>
</record>
+27 -6
View File
@@ -9,16 +9,22 @@ openerp.mail = function(session) {
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() {
this.timeout;
// this.timeout;
this._super.apply(this, arguments);
this.ds = new session.web.DataSet(this, this.view.model);
},
start: function() {
var self = this;
this._super.apply(this, arguments);
self.$element.find('button.oe_mail_action_follow').bind('click', function () { self.do_follow(); });
self.$element.find('button.oe_mail_action_unfollow').bind('click', function () { self.do_unfollow(); });
},
stop: function () {
clearTimeout(this.timeout);
// clearTimeout(this.timeout);
this._super();
},
@@ -34,12 +40,27 @@ openerp.mail = function(session) {
},
display_records: function (records) {
// this.$element.empty();
console.log(records);
// this.$element.empty();
var self = this;
_(records).each(function (record) {
$('<div>').text(record.user_id[1]).appendTo(self.$element);
// $('<div>').text(record.user_id['1']).appendTo(self.$element);
// $('<div style="width:75%;">').text(record.body_text).appendTo(self.$element);
$('<div>').text(record.body_text).appendTo(self.$element);
// $('<p>').text(record.user_id).appendTo(self.$element);
});
this.timeout = setTimeout(this.proxy('fetch_messages'), 5000);
// this.timeout = setTimeout(this.proxy('fetch_messages'), 5000);
},
do_follow: function () {
var self = this;
console.log('Follow');
},
do_unfollow: function () {
var self = this;
console.log('Unfollow');
}
});
+11 -1
View File
@@ -2,7 +2,17 @@
<template>
<div t-name="MailTest">
vdvgfxdfxdfv
<button type="button" class="oe_mail_action_follow">
Follow
<!-- <img src="/edi/static/src/img/pdf.png"/> -->
</button>
<button type="button" class="oe_mail_action_unfollow">
Unfollow
<!-- <img src="/edi/static/src/img/pdf.png"/> -->
</button>
<p>Bladivoctock !</p>
<t t-if="type=='comment'">Blougiboulga !!</t>
<p>Ouagadougou</p>
</div>
<!-- <t t-extend="ViewManagerAction">