You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.7 KiB
40 lines
1.7 KiB
# -*- coding: utf-8 -*-
|
|
# Copyright 2016 Odoo SA <https://www.odoo.com>
|
|
# Copyright 2018 Therp BV <http://therp.nl>
|
|
# Copyright 2018 Eficent <http://www.eficent.com>
|
|
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
|
|
from openerp import api, models
|
|
|
|
|
|
class CalendarEvent(models.Model):
|
|
_inherit = 'calendar.event'
|
|
|
|
@api.model
|
|
def default_get(self, fields):
|
|
if self.env.context.get('default_opportunity_id'):
|
|
self = self.with_context(
|
|
default_res_model_id=self.env.ref('crm.model_crm_lead').id,
|
|
default_res_id=self.env.context['default_opportunity_id']
|
|
)
|
|
defaults = super(CalendarEvent, self).default_get(fields)
|
|
|
|
# sync res_model / res_id to opportunity id (aka
|
|
# creating meeting from lead chatter)
|
|
if 'opportunity_id' not in defaults and defaults.get('res_id') and \
|
|
(defaults.get('res_model') or defaults.get('res_model_id')):
|
|
if (defaults.get('res_model') and
|
|
defaults['res_model'] == 'crm.lead') or \
|
|
(defaults.get('res_model_id') and self.env[
|
|
'ir.model'].sudo().browse(
|
|
defaults['res_model_id']).model == 'crm.lead'):
|
|
defaults['opportunity_id'] = defaults['res_id']
|
|
|
|
return defaults
|
|
|
|
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
|