Before this commit, Odoo notifies the user of all the recurring past events, existing before the installation of the module Calendar (old events imported when synchronizing with Google, for instance). This occurs only the first time a synchronization with Google is made. This occurs because Odoo notify all the events that occurs since the last time it notified, and the first time you install the module the date of the last notification is empty. Now, when the module Calendar is installed, the date of the last notification is set by default to the current date (the date of the installation of the module) opw-1942443 closes odoo/odoo#32535 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from datetime import datetime
|
|
|
|
from odoo import api, fields, models
|
|
|
|
from odoo.addons.calendar.models.calendar import get_real_ids
|
|
|
|
|
|
class Partner(models.Model):
|
|
_inherit = 'res.partner'
|
|
|
|
calendar_last_notif_ack = fields.Datetime('Last notification marked as read from base Calendar', default=fields.Datetime.now)
|
|
|
|
@api.multi
|
|
def get_attendee_detail(self, meeting_id):
|
|
""" Return a list of tuple (id, name, status)
|
|
Used by base_calendar.js : Many2ManyAttendee
|
|
"""
|
|
datas = []
|
|
meeting = None
|
|
if meeting_id:
|
|
meeting = self.env['calendar.event'].browse(get_real_ids(meeting_id))
|
|
|
|
for partner in self:
|
|
data = partner.name_get()[0]
|
|
data = [data[0], data[1], False, partner.color]
|
|
if meeting:
|
|
for attendee in meeting.attendee_ids:
|
|
if attendee.partner_id.id == partner.id:
|
|
data[2] = attendee.state
|
|
datas.append(data)
|
|
return datas
|
|
|
|
@api.model
|
|
def _set_calendar_last_notif_ack(self):
|
|
partner = self.env['res.users'].browse(self.env.uid).partner_id
|
|
partner.write({'calendar_last_notif_ack': datetime.now()})
|
|
return
|