Files
odoo_source/addons/calendar/models/mail_activity.py
T
Audric Onockx (auon) 700a50223e [FIX] calendar : Server error when mark a scheduled activity as done
Reproduce :

CRM.
Go to a task and schedule next activity.
Then mark this activity as done.
Write a feedback.
Result :

Server error traceback
Solution :

The written feedback is given as a kwarg to translate.
opw-2641747

closes odoo/odoo#76985

X-original-commit: 222bda82e034869590530fc634428dca596be198
Signed-off-by: Arnaud Joset <arj-odoo@users.noreply.github.com>
Signed-off-by: Audric Onockx <auon-odoo@users.noreply.github.com>
2021-09-23 08:36:57 +00:00

49 lines
1.9 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, models, fields, tools, _
class MailActivityType(models.Model):
_inherit = "mail.activity.type"
category = fields.Selection(selection_add=[('meeting', 'Meeting')])
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 and tools.html2plaintext(self.note).strip() or '',
'default_activity_ids': [(6, 0, self.ids)],
}
return action
def _action_done(self, feedback=False, attachment_ids=False):
events = self.mapped('calendar_event_id')
messages, activities = super(MailActivity, self)._action_done(feedback=feedback, attachment_ids=attachment_ids)
if feedback:
for event in events:
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 messages, activities
def unlink_w_meeting(self):
events = self.mapped('calendar_event_id')
res = self.unlink()
events.unlink()
return res