diff --git a/addons/calendar/models/calendar.py b/addons/calendar/models/calendar.py index 55c9b5065ec..639239420ca 100644 --- a/addons/calendar/models/calendar.py +++ b/addons/calendar/models/calendar.py @@ -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): diff --git a/addons/calendar/views/calendar_views.xml b/addons/calendar/views/calendar_views.xml index 98ceae11042..41594154d90 100644 --- a/addons/calendar/views/calendar_views.xml +++ b/addons/calendar/views/calendar_views.xml @@ -270,6 +270,7 @@ + diff --git a/addons/crm/models/calendar.py b/addons/crm/models/calendar.py index 6c704e2ce39..e30fda1c847 100644 --- a/addons/crm/models/calendar.py +++ b/addons/crm/models/calendar.py @@ -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 diff --git a/addons/crm/models/crm_lead.py b/addons/crm/models/crm_lead.py index e24e3404042..35de09125da 100644 --- a/addons/crm/models/crm_lead.py +++ b/addons/crm/models/crm_lead.py @@ -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, diff --git a/addons/hr_recruitment/models/__init__.py b/addons/hr_recruitment/models/__init__.py index 229232b7029..b51b441688d 100644 --- a/addons/hr_recruitment/models/__init__.py +++ b/addons/hr_recruitment/models/__init__.py @@ -3,3 +3,4 @@ import hr_recruitment import hr_employee import hr_job import hr_recruitment_config_settings +import calendar diff --git a/addons/hr_recruitment/models/calendar.py b/addons/hr_recruitment/models/calendar.py new file mode 100644 index 00000000000..0a2bbe04c86 --- /dev/null +++ b/addons/hr_recruitment/models/calendar.py @@ -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 diff --git a/addons/web_calendar/static/src/js/web_calendar.js b/addons/web_calendar/static/src/js/web_calendar.js index 6f1be2bd5c4..109abc71d41 100644 --- a/addons/web_calendar/static/src/js/web_calendar.js +++ b/addons/web_calendar/static/src/js/web_calendar.js @@ -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; }, diff --git a/addons/web_calendar/static/src/less/web_calendar.less b/addons/web_calendar/static/src/less/web_calendar.less index 9eb29fb701c..ab87c86727e 100644 --- a/addons/web_calendar/static/src/less/web_calendar.less +++ b/addons/web_calendar/static/src/less/web_calendar.less @@ -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); }