From 63167fc51b70cd1a51fb8bb75968aade4f0e0071 Mon Sep 17 00:00:00 2001 From: Mahendra barad Date: Wed, 8 Mar 2017 11:41:11 +0530 Subject: [PATCH] [IMP] mail: allow users to give schedule and give a feedback on activities When setting an activity as done in chatter users now have the possibility to add a feedback. This feedback is added in the generated message that already contains the activity name and note. Moreover users now can also immediately schedule a next activity. This is very useful for chained activities and speeds up activities use. --- addons/mail/models/mail_activity.py | 5 ++- addons/mail/static/src/js/activity.js | 44 +++++++++++++++++++++++-- addons/mail/static/src/xml/activity.xml | 15 ++++++++- addons/mail/views/mail_templates.xml | 1 + 4 files changed, 60 insertions(+), 5 deletions(-) diff --git a/addons/mail/models/mail_activity.py b/addons/mail/models/mail_activity.py index 39fe471bcc4..2f9c9f576ff 100644 --- a/addons/mail/models/mail_activity.py +++ b/addons/mail/models/mail_activity.py @@ -65,6 +65,7 @@ class MailActivity(models.Model): icon = fields.Char('Icon', related='activity_type_id.icon') summary = fields.Char('Summary') note = fields.Html('Note') + feedback = fields.Html('Feedback') date_deadline = fields.Date('Deadline', index=True, required=True, default=fields.Date.today) # description user_id = fields.Many2one( @@ -117,8 +118,10 @@ class MailActivity(models.Model): return res @api.multi - def action_done(self): + def action_done(self, feedback=False): message = self.env['mail.message'] + if feedback: + self.write(dict(feedback=feedback)) for activity in self: record = self.env[activity.res_model].browse(activity.res_id) record.message_post_with_view( diff --git a/addons/mail/static/src/js/activity.js b/addons/mail/static/src/js/activity.js index 2978ac8a458..1c4ad64eab1 100644 --- a/addons/mail/static/src/js/activity.js +++ b/addons/mail/static/src/js/activity.js @@ -187,11 +187,49 @@ var Activity = form_common.AbstractField.extend({ }, on_activity_done: function (event) { - event.preventDefault(); var self = this; - var activity_id = this.$(event.currentTarget).data('activity-id'); + event.preventDefault(); + var $popover_el = this.$(event.currentTarget); + var activity_id = $popover_el.data('activity-id'); + if(! $popover_el.data('bs.popover')) { + $popover_el.popover({ + title : _t('Feedback'), + html: 'true', + trigger:'click', + content : function() { + var $popover = $(QWeb.render("mail.activity_feedback_form", {})); + $popover.on('click', '.o_activity_popover_done_next', function (e) { + self.set_done(activity_id, _.escape($popover.find('#activity_feedback').val())); + self.on_activity_schedule(e); + }); + $popover.on('click', '.o_activity_popover_done', function () { + self.set_done(activity_id, _.escape($popover.find('#activity_feedback').val())); + }); + $popover.on('click', '.o_activity_popover_discard', function () { + $popover_el.popover('hide'); + }); + return $popover; + }, + }).on("show.bs.popover", function (e) { + $(".popover").not(e.target).popover("hide"); + }).on("shown.bs.popover", function () { + var $popover = $(this).data("bs.popover").tip(); + $popover.css({maxWidth: "410px"}).attr('tabindex', 0); + $popover.find('#activity_feedback').focus(); + // Outside click of popover hide the popover + $popover.focusout(function (e) { + if(!e.relatedTarget) { + $popover.popover('hide'); + } + }); + }).popover('show'); + } + }, + + set_done: function (activity_id, feedback) { + var self = this; this.Activity - .call("action_done", [[activity_id]]) + .call("action_done", [[activity_id]], {'feedback': feedback}) .then(function (msg_id) { self.fetch_and_render_value(); diff --git a/addons/mail/static/src/xml/activity.xml b/addons/mail/static/src/xml/activity.xml index 92f15abcc9a..5fc6346182c 100644 --- a/addons/mail/static/src/xml/activity.xml +++ b/addons/mail/static/src/xml/activity.xml @@ -9,7 +9,7 @@
- +
@@ -41,4 +41,17 @@
+ +
+