Files
odoo_source/addons/calendar/models/mail_activity.py
T
bit-odoo fff449a419 [IMP] calendar: calendar app should open on due date with pop-up opened
PURPOSE

Calendar app should open with pop-up opened

SPECIFICATIONS

When activity of type meeting is edited(Reschedule), he gets a calendar
app open on due date's week.The calendar app should be opened with the
corresponding meeting highlighted (or the pop-up opened same as if the user
has click on it)

Task-2528115

closes odoo/odoo#72544

Signed-off-by: Arnaud Joset (arj) <arj@odoo.com>
2023-06-14 20:20:43 +02:00

46 lines
1.9 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models, fields, tools, _
from odoo.tools import is_html_empty
class MailActivity(models.Model):
_inherit = "mail.activity"
calendar_event_id = fields.Many2one('calendar.event', string="Calendar Meeting", ondelete='cascade')
def action_create_calendar_event(self):
self.ensure_one()
action = self.env["ir.actions.actions"]._for_xml_id("calendar.action_calendar_event")
action['context'] = {
'default_activity_type_id': self.activity_type_id.id,
'default_res_id': self.env.context.get('default_res_id'),
'default_res_model': self.env.context.get('default_res_model'),
'default_name': self.summary or self.res_name,
'default_description': self.note if not is_html_empty(self.note) else '',
'default_activity_ids': [(6, 0, self.ids)],
'default_partner_ids': self.user_id.partner_id.ids,
'default_user_id': self.user_id.id,
'initial_date': self.date_deadline,
'default_calendar_event_id': self.calendar_event_id.id,
}
return action
def _action_done(self, feedback=False, attachment_ids=False):
if feedback:
for event in self.calendar_event_id:
description = event.description
description = '%s<br />%s' % (
description if not tools.is_html_empty(description) else '',
_('Feedback: %(feedback)s', feedback=tools.plaintext2html(feedback)) if feedback else '',
)
event.write({'description': description})
return super(MailActivity, self)._action_done(feedback=feedback, attachment_ids=attachment_ids)
def unlink_w_meeting(self):
events = self.mapped('calendar_event_id')
res = self.unlink()
events.unlink()
return res