[IMP] calendar: add highlighting in dependant modules
Now, calendar event relative to a document (ex: crm.lead, hr.applicant) are highlighted when comming from there form view. The mecanism consist in override the method of the computed field 'is_highlighted'.
This commit is contained in:
@@ -648,6 +648,13 @@ class Meeting(models.Model):
|
||||
return round(duration, 2)
|
||||
return 0.0
|
||||
|
||||
def _compute_is_highlighted(self):
|
||||
if self.env.context.get('active_model') == 'res.partner':
|
||||
partner_id = self.env.context.get('active_id')
|
||||
for event in self:
|
||||
if event.partner_ids.filtered(lambda s: s.id == partner_id):
|
||||
event.is_highlighted = True
|
||||
|
||||
name = fields.Char('Meeting Subject', required=True, states={'done': [('readonly', True)]})
|
||||
state = fields.Selection([('draft', 'Unconfirmed'), ('open', 'Confirmed')], string='Status', readonly=True, track_visibility='onchange', default='draft')
|
||||
|
||||
@@ -725,6 +732,7 @@ class Meeting(models.Model):
|
||||
attendee_ids = fields.One2many('calendar.attendee', 'event_id', 'Participant', ondelete='cascade')
|
||||
partner_ids = fields.Many2many('res.partner', 'calendar_event_res_partner_rel', string='Attendees', states={'done': [('readonly', True)]}, default=_default_partners)
|
||||
alarm_ids = fields.Many2many('calendar.alarm', 'calendar_alarm_calendar_event_rel', string='Reminders', ondelete="restrict", copy=False)
|
||||
is_highlighted = fields.Boolean(compute='_compute_is_highlighted', string='# Meetings Highlight')
|
||||
|
||||
@api.multi
|
||||
def _compute_attendee(self):
|
||||
|
||||
@@ -270,6 +270,7 @@
|
||||
<field name="user_id"/>
|
||||
<field name="color_partner_id"/>
|
||||
<field name="partner_ids"/>
|
||||
<field name="is_highlighted"/>
|
||||
</calendar>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -8,6 +8,14 @@ class CalendarEvent(models.Model):
|
||||
|
||||
_inherit = 'calendar.event'
|
||||
|
||||
def _compute_is_highlighted(self):
|
||||
super(CalendarEvent, self)._compute_is_highlighted()
|
||||
if self.env.context.get('active_model') == 'crm.lead':
|
||||
opportunity_id = self.env.context.get('active_id')
|
||||
for event in self:
|
||||
if event.opportunity_id.id == opportunity_id:
|
||||
event.is_highlighted = True
|
||||
|
||||
opportunity_id = fields.Many2one('crm.lead', 'Opportunity', domain="[('type', '=', 'opportunity')]")
|
||||
|
||||
@api.model
|
||||
|
||||
@@ -377,7 +377,6 @@ class Lead(FormatAddress, models.Model):
|
||||
if self.partner_id:
|
||||
partner_ids.append(self.partner_id.id)
|
||||
action['context'] = {
|
||||
'search_default_opportunity_id': self.id if self.type == 'opportunity' else False,
|
||||
'default_opportunity_id': self.id if self.type == 'opportunity' else False,
|
||||
'default_partner_id': self.partner_id.id,
|
||||
'default_partner_ids': partner_ids,
|
||||
|
||||
@@ -3,3 +3,4 @@ import hr_recruitment
|
||||
import hr_employee
|
||||
import hr_job
|
||||
import hr_recruitment_config_settings
|
||||
import calendar
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class CalendarEvent(models.Model):
|
||||
""" Model for Calendar Event """
|
||||
_inherit = 'calendar.event'
|
||||
|
||||
def _compute_is_highlighted(self):
|
||||
super(CalendarEvent, self)._compute_is_highlighted()
|
||||
applicant_id = self.env.context.get('active_id')
|
||||
if self.env.context.get('active_model') == 'hr.applicant' and applicant_id:
|
||||
for event in self:
|
||||
if event.applicant_id.id == applicant_id:
|
||||
event.is_highlighted = True
|
||||
|
||||
applicant_id = fields.Many2one('hr.applicant', string="Applicant")
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
res = super(CalendarEvent, self).create(vals)
|
||||
applicant_id = self.env.context.get('active_id')
|
||||
if self.env.context.get('active_model') == 'hr.applicant' and applicant_id:
|
||||
res.applicant_id = applicant_id
|
||||
return res
|
||||
@@ -661,6 +661,9 @@ var CalendarView = View.extend({
|
||||
} else { // if form all, get color -1
|
||||
r.className = 'o_calendar_color_'+ (self.all_filters[-1] ? self.all_filters[-1].color : 1);
|
||||
}
|
||||
if (evt.is_highlighted) {
|
||||
r.className += ' o_event_hightlight';
|
||||
}
|
||||
return r;
|
||||
},
|
||||
|
||||
|
||||
@@ -11,6 +11,10 @@
|
||||
background-color: spin(rgb(255, 192, 192), 360/(@nb-calendar-colors+1) * @index);
|
||||
border-color: spin(rgb(255, 192, 192), 360/(@nb-calendar-colors+1) * @index);
|
||||
opacity: 0.7;
|
||||
&.o_event_hightlight {
|
||||
font-weight: bold;
|
||||
opacity: 0.9;
|
||||
}
|
||||
}
|
||||
.calendar_color_loop(@index + 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user