[IMP] mail: remove duplicated logs when scheduling activities and improve template

Currently when scheduling activities, duplicate logs are created. Indeed
a message is posted when scheduling an activity, editing it and marking it
as done. This leads to a lot of noise being created on records.

This commit remove logs when scheduling and updating an activity. A sole
message is posted when the activity is marked as done.

Scheduled activity display in chatter is also improved to better
differentiate the user creating the activity from the user who is
assigned to the activity.
This commit is contained in:
Mahendra barad
2017-03-03 11:40:50 +01:00
committed by Thibault Delavallée
parent 09de7be22c
commit 26940f8de4
4 changed files with 18 additions and 31 deletions
+4 -14
View File
@@ -105,27 +105,17 @@ class MailActivity(models.Model):
@api.model
def create(self, values):
activity = super(MailActivity, self).create(values)
activity.post_assignation_message()
self.env[activity.res_model].browse(activity.res_id).message_subscribe(partner_ids=[activity.user_id.partner_id.id])
return activity
@api.multi
def write(self, values):
res = super(MailActivity, self).write(values)
if values.get('user_id'):
self.post_assignation_message()
for activity in self:
self.env[activity.res_model].browse(activity.res_id).message_subscribe(partner_ids=[activity.user_id.partner_id.id])
return res
def post_assignation_message(self):
for activity in self:
record = self.env[activity.res_model].browse(activity.res_id)
record.with_context(
mail_post_autofollow=True
).message_post_with_view(
'mail.message_activity_assigned',
values={'activity': activity},
partner_ids=[activity.user_id.partner_id.id],
subtype_id=self.env.ref('mail.mt_note').id,
)
@api.multi
def action_done(self):
message = self.env['mail.message']
+4
View File
@@ -7,6 +7,7 @@ var Model = require("web.Model");
var Widget = require('web.Widget');
var ChatManager = require('mail.chat_manager');
var QWeb = core.qweb;
var time = require('web.time');
var _t = core._t;
@@ -113,6 +114,9 @@ var Activity = form_common.AbstractField.extend({
return this.Activity
.call("read", [this.value])
.then(function (results) {
_.each(results, function(result){
result['time_ago'] = moment(time.auto_str_to_date(result.create_date)).fromNow();
});
this.activities = set_delay_label(results);
self.$el.html(QWeb.render('mail.activity_items', {
activities: this.activities,
+10 -3
View File
@@ -16,16 +16,23 @@
<strong>
<span t-attf-class="fa #{activity.icon}" />
<t t-esc="activity.activity_type_id[1]" />
</strong> planned by <strong><t t-esc="activity.user_id[1]" /></strong>
</strong>
<span class="fa fa-clock-o ml8" />
<span t-attf-class="o_activity_date o_activity_color_#{activity.state}"><t t-esc="activity.label_delay" /></span>
<strong>
<span t-attf-class="o_activity_date o_activity_color_#{activity.state}"><t t-esc="activity.label_delay" /> (<t t-esc="activity.date_deadline"/>) </span>
</strong>
planned by <t t-esc="activity.create_uid[1]" />
<t t-if="activity.create_uid[0] != activity.user_id[0]">
for <t t-esc="activity.user_id[1]" />
</t>
- <t t-esc="activity.time_ago"/>
<div class="pull-right">
<a href="#" class="o_activity_edit o_activity_link" t-att-data-activity-id="activity.id">Edit</a> |
<a href="#" class="o_activity_unlink o_activity_link" t-att-data-activity-id="activity.id">Remove</a>
</div>
</div>
<div t-if="activity.summary">
<strong><i><t t-esc="activity.summary"/></i></strong>
<strong><t t-esc="activity.summary"/></strong>
</div>
<div t-if="activity.note">
<t t-raw="activity.note"/>
-14
View File
@@ -64,19 +64,5 @@
</div>
</template>
<template id="message_activity_assigned">
<div>
<p>
Planned <span t-field="activity.activity_type_id.name"/> related to <t t-esc="object.name_get()[0][1]"/>:
<soan t-if="activity.summary" t-field="activity.summary"/>
</p>
<ul>
<li>Scheduled for: <span t-field="activity.date_deadline"/></li>
<li>Assigned to: <span t-field="activity.user_id.name"/></li>
</ul>
<div t-if="activity.note" t-field="activity.note"/>
</div>
</template>
</data>
</odoo>