diff --git a/addons/hr_holidays/hr_holidays.py b/addons/hr_holidays/hr_holidays.py
index 3bb7a8e4982..2ddb6e87a3a 100644
--- a/addons/hr_holidays/hr_holidays.py
+++ b/addons/hr_holidays/hr_holidays.py
@@ -93,6 +93,7 @@ class hr_holidays(osv.osv):
_name = "hr.holidays"
_description = "Leave"
_order = "type desc, date_from asc"
+ _inherit = ['mail.thread']
def _employee_get(self, cr, uid, context=None):
ids = self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', uid)], context=context)
@@ -250,8 +251,16 @@ class hr_holidays(osv.osv):
obj_emp = self.pool.get('hr.employee')
ids2 = obj_emp.search(cr, uid, [('user_id', '=', uid)])
manager = ids2 and ids2[0] or False
+ self.holidays_validate_notificate(cr, uid, ids, context=context)
return self.write(cr, uid, ids, {'state':'validate1', 'manager_id': manager})
+ 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)
+ self.message_append_note(cr, uid, [obj.id], 'System notification', _("The %s request '%s' has been validated.") % ('leave' if obj.type == 'remove' else 'allocation', obj.name,), type='notification', context=context)
+ if obj.holiday_status_id.double_validation:
+ self.message_append_note(cr, uid, [obj.id], 'System notification', _("The %s request '%s' is waiting for second validation.") % ('leave' if obj.type == 'remove' else 'allocation', obj.name,), type='notification', context=context)
+
def holidays_validate2(self, cr, uid, ids, context=None):
self.check_holidays(cr, uid, ids, context=context)
obj_emp = self.pool.get('hr.employee')
@@ -301,13 +310,23 @@ class hr_holidays(osv.osv):
wf_service.trg_validate(uid, 'hr.holidays', leave_id, 'validate', cr)
wf_service.trg_validate(uid, 'hr.holidays', leave_id, 'second_validate', cr)
if holiday_ids:
+ self.holidays_valid2_notificate(self, cr, uid, [holiday_ids], context=context)
self.write(cr, uid, holiday_ids, {'manager_id2': manager})
return True
+
+ def holidays_valid2_notificate(self, cr, uid, ids, context=None):
+ for obj in self.browse(cr, uid, ids):
+ self.message_append_note(cr, uid, [obj.id], 'System notification', _("The %s request '%s' has been double validated.") % ('leave' if obj.type == 'remove' else 'allocation', obj.name,), type='notification', context=context)
def holidays_confirm(self, cr, uid, ids, context=None):
self.check_holidays(cr, uid, ids, context=context)
+ self.holidays_confirm_notificate(cr, uid, ids, context=context)
return self.write(cr, uid, ids, {'state':'confirm'})
-
+
+ def holidays_confirm_notificate(self, cr, uid, ids, context=None):
+ 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.") % ('leave' if obj.type == 'remove' else 'allocation', obj.name,), type='notification', need_action_user_id=obj.employee_id.parent_id.user_id.id)
+
def holidays_refuse(self, cr, uid, ids, approval, context=None):
obj_emp = self.pool.get('hr.employee')
ids2 = obj_emp.search(cr, uid, [('user_id', '=', uid)])
diff --git a/addons/hr_holidays/hr_holidays_view.xml b/addons/hr_holidays/hr_holidays_view.xml
index 22d4d6e567d..2096ae2bc61 100644
--- a/addons/hr_holidays/hr_holidays_view.xml
+++ b/addons/hr_holidays/hr_holidays_view.xml
@@ -95,6 +95,7 @@
+
diff --git a/addons/mail/mail_group.py b/addons/mail/mail_group.py
index 50141bf27a0..a669f736013 100644
--- a/addons/mail/mail_group.py
+++ b/addons/mail/mail_group.py
@@ -49,12 +49,6 @@ class mail_group(osv.osv):
return True
- def action_test(self, cr, uid, ids, context={}):
- for o in self.browse(cr, uid, ids):
- message = _('You are doing things with the group %s, wooooh !') % (o.name,)
- self.log(cr, uid, o.id, message)
- return True
-
def action_null(self, cr, uid, ids, context={}):
return True
diff --git a/addons/mail/mail_group_view.xml b/addons/mail/mail_group_view.xml
index d4185c4ae97..7c409b9cdfd 100644
--- a/addons/mail/mail_group_view.xml
+++ b/addons/mail/mail_group_view.xml
@@ -49,9 +49,7 @@
-
-
@@ -84,15 +82,5 @@
-
-
\ No newline at end of file
diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py
index 1ff719447e4..6543dc63463 100644
--- a/addons/mail/mail_message.py
+++ b/addons/mail/mail_message.py
@@ -197,17 +197,23 @@ class mail_message(osv.osv):
#------------------------------------------------------
def create(self, cr, uid, vals, context=None):
+ # OpenSocial: notifications do not come from any user but from system
+ if vals['type'] == 'notification': vals['user_id'] = False
+ need_action_pushed = False
msg_id = super(mail_message, self).create(cr, uid, vals, context)
# push the message to suscribed users
subscription_obj = self.pool.get('mail.subscription')
notification_obj = self.pool.get('mail.notification')
- sub_ids = subscription_obj.search(cr, uid, ['&', '&',
+ sub_ids = subscription_obj.search(cr, uid, ['&',
('res_model', '=', vals['model']),
- ('user_id', '=', uid),
('res_id', '=', vals['res_id'])], context=context)
subs = subscription_obj.browse(cr, uid, sub_ids, context=context)
for sub in subs:
notification_obj.create(cr, uid, {'user_id': sub.user_id, 'message_id': msg_id}, context=context)
+ if vals['need_action_user_id'] == sub.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'] != False and not need_action_pushed:
+ notification_obj.create(cr, uid, {'user_id': vals['need_action_user_id'], 'message_id': msg_id}, context=context)
return msg_id
def get_pushed_messages(self, cr, uid, context=None):
diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py
index 0fac416a72b..f582bc50062 100644
--- a/addons/mail/mail_thread.py
+++ b/addons/mail/mail_thread.py
@@ -506,10 +506,8 @@ class mail_thread(osv.osv):
# Note specific
#------------------------------------------------------
- def message_append_note(self, cr, uid, ids, subject, body, type='notification', need_action=False,
- need_action_user_id=False, context=None):
- return self.message_append(cr, uid, ids, subject, body_text=body, type=type, need_action=need_action,
- need_action_user_id=need_action_user_id, context=context)
+ 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)
# old log overrided method: now calls message_append_note
def log(self, cr, uid, id, message, secondary=False, context=None):
@@ -523,8 +521,17 @@ class mail_thread(osv.osv):
if context and context.get('disable_log'):
#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)
+ #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')
+ for id in ids:
+ msg_ids = msg_obj.search(cr, uid, ['&', ('res_id', '=', id), ('model', '=', self._name)], context=context)
+ msg_obj.write(cr, uid, msg_ids, {'need_action_user_id': False}, context=context)
+
#------------------------------------------------------
# Subscription mechanism
#------------------------------------------------------
diff --git a/addons/mail/mail_thread_view.xml b/addons/mail/mail_thread_view.xml
index 8b3afe362cd..8b2ae76824d 100644
--- a/addons/mail/mail_thread_view.xml
+++ b/addons/mail/mail_thread_view.xml
@@ -50,5 +50,15 @@
+
+
diff --git a/addons/mail/security/ir.model.access.csv b/addons/mail/security/ir.model.access.csv
index 07a3a1cde3b..88482da473e 100644
--- a/addons/mail/security/ir.model.access.csv
+++ b/addons/mail/security/ir.model.access.csv
@@ -1,3 +1,5 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_mail_message,mail.message,model_mail_message,,1,0,1,0
access_mail_thread,mail.thread,model_mail_thread,,1,0,1,0
+access_mail_subscription,mail.subscription,model_mail_subscription,,1,0,1,0
+access_mail_notification,mail.notification,model_mail_notification,,1,0,1,0
diff --git a/addons/mail/static/src/css/mail.css b/addons/mail/static/src/css/mail.css
index 874e22624f5..906bdbff6cf 100644
--- a/addons/mail/static/src/css/mail.css
+++ b/addons/mail/static/src/css/mail.css
@@ -1,13 +1,25 @@
/** ThreadView widget **/
-.oe_mail_comment {
+.oe_mail_main {
+}
+
+.oe_mail_actions {
+ padding-bottom: 10px;
+}
+
+.oe_mail_post_comment {
+ width: 65%;
+ padding-bottom: 10px;
+}
+
+.oe_mail_comments {
width: 65%;
- border: 4px solid #770033;
}
.oe_mail_msg {
- width: 80%;
- border: 4px solid #998877;
+ width: 65%;
+/* border: 1px solid #998877; */
+ padding: 10px 0px 10px 0px;
}
.oe_mail_msg:after {
@@ -18,27 +30,32 @@
.oe_mail_msg_image {
float: left;
- width: 10%;
+ width: 9%;
}
.oe_mail_msg_content {
- float: right;
- width: 80%;
- border: 4px solid #557722;
+ width: 89%;
+ margin-left: 10%;
+/* border: 1px solid #557722; */
+ overflow: hidden;
+}
+
+.oe_mail_msg_p {
+ padding: 0;
+ margin: 0;
}
.oe_mail_msg_body {
}
.oe_mail_msg_author {
+ color: #4E43E7;
+}
+
+.oe_mail_msg_need_action {
+ color: #C03000;
}
.oe_mail_msg_date {
-}
-
-.oe_mail_msg_p {
- padding: 0;
- margin: 0;
- width: 25%;
- word-wrap: break-word;
+ color: #4E43E7;
}
diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js
index c5498d97dd9..4157aef5a33 100644
--- a/addons/mail/static/src/js/mail.js
+++ b/addons/mail/static/src/js/mail.js
@@ -4,6 +4,8 @@ openerp.mail = function(session) {
session.web.form.widgets.add(
'ThreadView', 'openerp.mail.ThreadView');
+ session.web.page.readonly.add(
+ 'ThreadView', 'openerp.mail.ThreadView');
/* ThreadView Widget: thread of comments */
mail.ThreadView = session.web.form.Field.extend({
@@ -11,17 +13,16 @@ openerp.mail = function(session) {
template: 'ThreadView',
init: function() {
- this.timeout;
+// this.timeout;
this.follow_state = 0;
this._super.apply(this, arguments);
/* DataSets */
this.ds = new session.web.DataSet(this, this.view.model);
this.ds_sub = new session.web.DataSet(this, 'mail.subscription');
- this.ds_msg = new session.web.DataSet(this, 'mail.message');
+// this.ds_msg = new session.web.DataSet(this, 'mail.message');
},
start: function() {
- console.log('Entering start');
var self = this;
this._super.apply(this, arguments);
/* bind follow and unfollow buttons */
@@ -32,27 +33,20 @@ openerp.mail = function(session) {
self.$element.find('button.oe_mail_action_comment').bind('click', function () { self.do_comment(); });
/* find wich (un)follow buttons to show */
var call_res = this.ds.call('message_is_subscriber', [[this.session.uid]]).then(function (records) {
- if (records == true) { self.follow_state = 1; console.log('brout!'); self.$element.find('button.oe_mail_action_unfollow').show(); }
- else { self.follow_state = 0; console.log('proutch!'); self.$element.find('button.oe_mail_action_follow').show(); }
+ if (records == true) { self.follow_state = 1; self.$element.find('button.oe_mail_action_unfollow').show(); }
+ else { self.follow_state = 0; self.$element.find('button.oe_mail_action_follow').show(); }
});
- console.log(call_res);
- console.log('Leaving start');
},
stop: function () {
// clearTimeout(this.timeout);
- console.log('Entering stop');
this._super();
- console.log('Leaving stop');
},
set_value: function() {
- console.log('Entering set_value');
this._super.apply(this, arguments);
if (! this.view.datarecord.id) { return; }
- var fetch_res = this.fetch_messages();
- console.log('Leaving set_value');
- return fetch_res
+ return this.fetch_messages();
},
fetch_messages: function () {
@@ -61,40 +55,34 @@ openerp.mail = function(session) {
},
display_records: function (records) {
- console.log(records);
-// this.$element.empty();
+ 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);
+ $('
').html(render_res).appendTo(self.$element.find('div.oe_mail_comments'));
});
// this.timeout = setTimeout(this.proxy('fetch_messages'), 5000);
},
do_follow: function () {
- console.log('Follow');
- console.log(this);
this.$element.find('button.oe_mail_action_unfollow').show();
this.$element.find('button.oe_mail_action_follow').hide();
- return this.ds_sub.create({'res_model': this.view.model, 'user_id': this.session.uid, 'res_id': this.view.datarecord.id}).then(
- console.log('Subscription done'));
+ return this.ds_sub.create({'res_model': this.view.model, 'user_id': this.session.uid, 'res_id': this.view.datarecord.id}).then();
},
do_unfollow: function () {
- console.log('Unfollow');
this.$element.find('button.oe_mail_action_follow').show();
this.$element.find('button.oe_mail_action_unfollow').hide();
- return this.ds.call('message_unsubscribe', [[this.view.datarecord.id]]).then(
- console.log('Unfollowing'));
+ return this.ds.call('message_unsubscribe', [[this.view.datarecord.id]]).then();
},
do_comment: function () {
- console.log('Comment');
var body_text = this.$element.find('textarea').val();
- return this.ds_msg.call('create', [{'model': this.view.model, 'user_id': this.session.uid, 'res_id': this.view.datarecord.id, 'body_text': body_text, 'subject': 'Reply comment'}]).then(console.log('Comment posted'));
+ 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 35eefe53f16..376e8042a06 100644
--- a/addons/mail/static/src/xml/mail.xml
+++ b/addons/mail/static/src/xml/mail.xml
@@ -1,33 +1,39 @@
-
+
+
OpenSocial
Follow
Unfollow
-
-
-
-
-
- zmeofizepofinzepfoiznepfoizpfozeinfpzoeinfpoznf zfe zef zef ze fz efz efz ef zef ze fz efznf zfe zef zef ze fz efz efz ef zef ze fz efznf zfe zef zef ze fz efz efz ef zef ze fz ef
-
-
Image
-
-
- zmeofizepofinzepfoiznepfoizpfozeinfpzoeinfpoznf zfe zef zef ze fz efz efz ef zef ze fz efznf zfe zef zef ze fz efz efz ef zef ze fz efznf zfe zef zef ze fz efz efz ef zef ze fz ef
-
-
-
-
-
-
+
+
+ Image
+
+
+
+ OpenERP System Notification
+
+
+
+
+
+
+
+ - Need action
+
+
+
+
+
+
+
\ No newline at end of file