diff --git a/addons/hr_holidays/hr_holidays.py b/addons/hr_holidays/hr_holidays.py
index f63dcf9632d..d5331624350 100644
--- a/addons/hr_holidays/hr_holidays.py
+++ b/addons/hr_holidays/hr_holidays.py
@@ -358,6 +358,14 @@ class hr_holidays(osv.osv):
# OpenChatter and notifications
# -----------------------------
+ def get_needaction_user_id(self, cr, uid, ids, name, arg, context=None):
+ result = {}
+ for obj in self.browse(cr, uid, ids, context=context):
+ result[obj.id] = False
+ if (obj.state == 'confirm' and obj.employee_id.parent_id):
+ result[obj.id] = obj.employee_id.parent_id.user_id.id
+ return result
+
def message_get_subscribers(self, cr, uid, ids, context=None):
sub_ids = self._message_get_subscribers_ids(cr, uid, ids, context=context);
# add the employee and its manager if specified to the subscribed users
@@ -377,12 +385,10 @@ class hr_holidays(osv.osv):
for obj in self.browse(cr, uid, ids):
self.message_append_note(cr, uid, [obj.id], _('System notification'),
_("The %s request '%s' has been confirmed and is waiting for validation by the manager.")
- % ('leave' if obj.type == 'remove' else 'allocation', obj.name,), type='notification',
- need_action_user_id = obj.employee_id.parent_id.user_id.id if obj.employee_id.parent_id else False)
+ % ('leave' if obj.type == 'remove' else 'allocation', obj.name,), type='notification')
def holidays_validate_notificate(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids):
- self.message_mark_done(cr, uid, [obj.id], context=context)
if obj.holiday_status_id.double_validation:
self.message_append_note(cr, uid, [obj.id], _('System notification'),
_("The %s request '%s' has been validated. A second validation is necessary and is now pending.")
diff --git a/addons/hr_holidays/hr_holidays_view.xml b/addons/hr_holidays/hr_holidays_view.xml
index 2096ae2bc61..34e2cb9bb14 100644
--- a/addons/hr_holidays/hr_holidays_view.xml
+++ b/addons/hr_holidays/hr_holidays_view.xml
@@ -95,6 +95,9 @@
+
+
+
diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py
index b22b0c792a8..429c85e91f7 100644
--- a/addons/mail/mail_message.py
+++ b/addons/mail/mail_message.py
@@ -184,7 +184,6 @@ class mail_message(osv.osv):
('comment', 'Comment'),
('notification', 'System 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_user_id': fields.many2one('res.users', 'Action by user', help="User requested to perform an action"),
}
_defaults = {
diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py
index 85c297fb07f..09fafd48a7e 100644
--- a/addons/mail/mail_thread.py
+++ b/addons/mail/mail_thread.py
@@ -53,6 +53,7 @@ class mail_thread(osv.osv):
'''
_name = 'mail.thread'
_description = 'Email Thread'
+ _inherit = ['res.needaction']
def _get_message_ids(self, cr, uid, ids, name, arg, context=None):
res = {}
@@ -88,36 +89,41 @@ class mail_thread(osv.osv):
# Generic message api
#------------------------------------------------------
- def message_create(self, cr, uid, ids, vals, context=None):
+ def message_create(self, cr, uid, thread_id, vals, context=None):
"""OpenSocial: wrapper of mail.message create method
- creates the mail.message
- automatically subscribe the message writer if not already done
- push the message to subscribed users"""
+ if context is None:
+ context = {}
+
subscription_obj = self.pool.get('mail.subscription')
notification_obj = self.pool.get('mail.notification')
# notifications do not come from any user, but from system
if vals.get('type') == 'notification': vals['user_id'] = False
- if not 'need_action_user_id' in vals: vals['need_action_user_id'] = False
if not 'model' in vals: vals['model'] = False
if not 'res_id' in vals: vals['res_id'] = 0
need_action_pushed = False
+ # create message
msg_id = self.pool.get('mail.message').create(cr, uid, vals, context=context)
+ obj = self.browse(cr, uid, [thread_id], context=context)[0]
# automatically subscribe the writer of the message if not subscribed
if vals['user_id']:
- if not self.message_is_subscriber(cr, uid, ids, context=context):
- self.message_subscribe(cr, uid, ids, context=context)
+ if not self.message_is_subscriber(cr, uid, [thread_id], context=context):
+ self.message_subscribe(cr, uid, [thread_id], context=context)
# push the message to suscribed users
- users = self.message_get_subscribers(cr, uid, ids, context=context)
+ users = self.message_get_subscribers(cr, uid, [thread_id], context=context)
for user in users:
notification_obj.create(cr, uid, {'user_id': user['id'], 'message_id': msg_id}, context=context)
- if vals['need_action_user_id'] == user['id']: need_action_pushed = True
+ # push to need_action_user_id
+ if obj.need_action_user_id == user['id']: need_action_pushed = True
# push to need_action_user_id if user does not follow the object
- if vals['need_action_user_id'] and not need_action_pushed:
- notification_obj.create(cr, uid, {'user_id': vals['need_action_user_id'], 'message_id': msg_id}, context=context)
+ if obj.need_action_user_id and not need_action_pushed:
+ notification_obj.create(cr, uid, {'user_id': obj.need_action_user_id.id, 'message_id': msg_id}, context=context)
return msg_id
def message_capable_models(self, cr, uid, context=None):
@@ -128,8 +134,7 @@ class mail_thread(osv.osv):
ret_dict[model_name] = model._description
return ret_dict
- def message_append(self, cr, uid, threads, subject, body_text=None,
- type='email', need_action_user_id=False,
+ def message_append(self, cr, uid, threads, subject, body_text=None, type='email',
email_to=False, email_from=False, email_cc=None, email_bcc=None,
reply_to=None, email_date=None, message_id=False, references=None,
attachments=None, body_html=None, subtype=None, headers=None,
@@ -215,7 +220,6 @@ class mail_thread(osv.osv):
'attachment_ids': [(6, 0, to_attach)],
'state': 'received',
'type': type,
- 'need_action_user_id': need_action_user_id,
}
if email_from:
@@ -247,7 +251,7 @@ class mail_thread(osv.osv):
}
#mail_message.create(cr, uid, data, context=context)
context['mail.thread'] = True
- self.message_create(cr, uid, [thread.id], data, context=context)
+ self.message_create(cr, uid, thread.id, data, context=context)
return True
def message_append_dict(self, cr, uid, ids, msg_dict, context=None):
@@ -272,7 +276,6 @@ class mail_thread(osv.osv):
subject = msg_dict.get('subject'),
body_text = msg_dict.get('body_text'),
type = msg_dict.get('type'),
- need_action_user_id = msg_dict.get('need_action_user_id'),
email_to = msg_dict.get('to'),
email_from = msg_dict.get('from'),
email_cc = msg_dict.get('cc'),
@@ -570,8 +573,8 @@ class mail_thread(osv.osv):
# Note specific
#------------------------------------------------------
- def message_append_note(self, cr, uid, ids, subject, body, type='notification', need_action_user_id=False, context=None):
- return self.message_append(cr, uid, ids, subject, body_text=body, type=type, need_action_user_id=need_action_user_id, context=context)
+ def message_append_note(self, cr, uid, ids, subject, body, type='notification', context=None):
+ return self.message_append(cr, uid, ids, subject, body_text=body, type=type, context=context)
# old log overrided method: now calls message_append_note
def log(self, cr, uid, id, message, secondary=False, context=None):
@@ -586,16 +589,6 @@ class mail_thread(osv.osv):
#return True # old behavior
print 'Log diabled, but we do not care currently about that. We want you to have our logs !'
#return self.message_append_note(cr, uid, [id], 'System notification', message, context=context)
-
- def message_mark_done(self, cr, uid, ids, context=None):
- """ OpenSocial add: mark a need_action message sa done
- Find by: res_id (thread id), model (self._name), need_action_user_id != false
- """
- msg_obj = self.pool.get('mail.message')
- msg_ids = msg_obj.search(cr, uid,
- ['&', '&', ('res_id', 'in', ids), ('model', '=', self._name), ('need_action_user_id', '!=', False)], context=context)
- msg_obj.write(cr, uid, msg_ids, {'need_action_user_id': False}, context=context)
- return True
#------------------------------------------------------
# Subscription mechanism
diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js
index b8a82ff0192..e88165045c2 100644
--- a/addons/mail/static/src/js/mail.js
+++ b/addons/mail/static/src/js/mail.js
@@ -98,6 +98,11 @@ openerp.mail = function(session) {
display_comments: function (records) {
var self = this;
+
+ // temporary verification of need_action_user_id (TODO: better display)
+ if (this.params.need_action_user_id) {
+ $('
').text('Need action by ' + this.params.need_action_user_id[1]).appendTo(self.$element.find('div.oe_mail_thread_display')); }
+
/* WIP: map matched regexp -> records to browse with name */
//_(records).each(function (record) {
//self.do_check_internal_links(record.body_text);
@@ -238,6 +243,7 @@ openerp.mail = function(session) {
},
set_value: function() {
+ console.log(this);
var self = this;
this._super.apply(this, arguments);
/* hide follow/unfollow/see followers buttons */
@@ -253,7 +259,8 @@ openerp.mail = function(session) {
this.fetch_subscribers();
/* create ThreadDisplay widget and render it */
this.$element.find('div.oe_mail_thread_left').empty();
- this.thread_display = new mail.ThreadDisplay(this, {'res_model': this.view.model, 'res_id': this.view.datarecord.id, 'uid': this.session.uid});
+ this.thread_display = new mail.ThreadDisplay(this, {'res_model': this.view.model, 'res_id': this.view.datarecord.id,
+ 'uid': this.session.uid, 'need_action_user_id': this.view.datarecord.need_action_user_id});
this.thread_display.appendTo(this.$element.find('div.oe_mail_thread_left'));
},
diff --git a/addons/mail/static/src/xml/mail.xml b/addons/mail/static/src/xml/mail.xml
index 1e4e301bc2e..c545af05e19 100644
--- a/addons/mail/static/src/xml/mail.xml
+++ b/addons/mail/static/src/xml/mail.xml
@@ -95,9 +95,6 @@
-
- - Need action by
-
wrote on