[IMP] mail: allow to decorate background of activity notes
In some case, we want to have a different style for activities that require attention for users. Sometimes activities should attract the user attention with actions to perform that are important. This commit introduces a decoration option on the activity type. By default no decoration is done. However decoration type can be set to warning or error. This triggers the related bootstrap alert classes. This commit is related to task ID #1860833. Closes #25479.
This commit is contained in:
committed by
Thibault Delavallée
parent
b094fc6bf8
commit
c30155c13c
@@ -6,6 +6,7 @@ import pytz
|
||||
|
||||
from odoo import api, exceptions, fields, models, _
|
||||
from odoo.osv import expression
|
||||
from odoo.tools import pycompat
|
||||
|
||||
|
||||
class MailActivityType(models.Model):
|
||||
@@ -34,6 +35,10 @@ class MailActivityType(models.Model):
|
||||
'Planned in', default=0,
|
||||
help='Number of days before executing the action. It allows to plan the action deadline.')
|
||||
icon = fields.Char('Icon', help="Font awesome icon e.g. fa-tasks")
|
||||
decoration_type = fields.Selection([
|
||||
('warning', 'Alert'),
|
||||
('danger', 'Error')], string="Decoration Type",
|
||||
help="Change the background color of the related activities of this type.")
|
||||
res_model_id = fields.Many2one(
|
||||
'ir.model', 'Model', index=True,
|
||||
domain=['&', ('is_mail_thread', '=', True), ('transient', '=', False)],
|
||||
@@ -85,6 +90,7 @@ class MailActivity(models.Model):
|
||||
'mail.activity.type', 'Activity',
|
||||
domain="['|', ('res_model_id', '=', False), ('res_model_id', '=', res_model_id)]", ondelete='restrict')
|
||||
activity_category = fields.Selection(related='activity_type_id.category')
|
||||
activity_decoration = fields.Selection(related='activity_type_id.decoration_type')
|
||||
icon = fields.Char('Icon', related='activity_type_id.icon')
|
||||
summary = fields.Char('Summary')
|
||||
note = fields.Html('Note')
|
||||
|
||||
@@ -201,8 +201,12 @@ var Activity = AbstractActivityField.extend({
|
||||
*/
|
||||
_render: function () {
|
||||
_.each(this._activities, function (activity) {
|
||||
if (activity.note) {
|
||||
var note = mailUtils.parseAndTransform(activity.note || '', mailUtils.inline);
|
||||
var is_blank = (/^\s*$/).test(note);
|
||||
if (!is_blank) {
|
||||
activity.note = mailUtils.parseAndTransform(activity.note, mailUtils.addLink);
|
||||
} else {
|
||||
activity.note = '';
|
||||
}
|
||||
});
|
||||
var activities = setDelayLabel(this._activities);
|
||||
|
||||
@@ -89,6 +89,10 @@
|
||||
|
||||
.o_thread_message_note {
|
||||
margin: 2px 0 5px;
|
||||
padding: 0px;
|
||||
}
|
||||
.o_thread_message_warning {
|
||||
margin: 2px 0 5px;
|
||||
}
|
||||
|
||||
.o_thread_message_tools {
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
<div t-if="activity.note" class="o_thread_message_note small">
|
||||
<div t-if="activity.note" t-attf-class="o_thread_message_#{activity.activity_decoration} #{activity.activity_decoration ? 'alert alert-' + activity.activity_decoration : ''} small">
|
||||
<t t-raw="activity.note"/>
|
||||
</div>
|
||||
<div class="o_thread_message_tools btn-group">
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
<field name="res_model_id" groups="base.group_no_one"/>
|
||||
<field name="summary"/>
|
||||
<field name="icon" groups="base.group_no_one"/>
|
||||
<field name="decoration_type" groups="base.group_no_one"/>
|
||||
<label for="days"/>
|
||||
<div>
|
||||
<field name="days" class="oe_inline"/>
|
||||
|
||||
Reference in New Issue
Block a user