19.0 vanilla

This commit is contained in:
Ernad Husremovic 2026-03-09 09:32:28 +01:00
parent 20ddc1b4a3
commit c0efcc53f5
1162 changed files with 125577 additions and 105287 deletions

View file

@ -1,17 +1,18 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import re
import logging
from odoo import api, models, Command
from odoo import api, models
from odoo.fields import Command, Domain
from odoo.tools import email_normalize
from odoo.addons.google_calendar.utils.google_calendar import GoogleCalendarService
_logger = logging.getLogger(__name__)
class RecurrenceRule(models.Model):
class CalendarRecurrence(models.Model):
_name = 'calendar.recurrence'
_inherit = ['calendar.recurrence', 'google.calendar.sync']
@ -42,7 +43,7 @@ class RecurrenceRule(models.Model):
}]
event.with_user(event._get_event_user())._google_delete(google_service, event.google_id)
event.google_id = False
self.env['calendar.event'].create(vals)
self.env['calendar.event'].with_context(skip_contact_description=True).create(vals)
self.calendar_event_ids.need_sync = False
return detached_events
@ -121,7 +122,7 @@ class RecurrenceRule(models.Model):
self.calendar_event_ids.write({'need_sync': False, 'partner_ids': [Command.unlink(att.partner_id.id) for att in attendees]})
old_event_values = self.base_event_id and self.base_event_id.read(base_event_time_fields)[0]
if old_event_values and any(new_event_values[key] != old_event_values[key] for key in base_event_time_fields):
if old_event_values and any(new_event_values.get(key) and new_event_values[key] != old_event_values[key] for key in base_event_time_fields):
# we need to recreate the recurrence, time_fields were modified.
base_event_id = self.base_event_id
non_equal_values = [
@ -173,7 +174,7 @@ class RecurrenceRule(models.Model):
# Google reuse the event google_id to identify the recurrence in that case
base_event = self.env['calendar.event'].search([('google_id', '=', vals['google_id'])])
if not base_event:
base_event = self.env['calendar.event'].create(base_values)
base_event = self.env['calendar.event'].with_context(skip_contact_description=True).create(base_values)
else:
# We override the base_event values because they could have been changed in Google interface
# The event google_id will be recalculated once the recurrence is created
@ -184,7 +185,7 @@ class RecurrenceRule(models.Model):
vals['event_tz'] = gevent.start.get('timeZone')
attendee_values[base_event.id] = {'attendee_ids': base_values.get('attendee_ids')}
recurrence = super(RecurrenceRule, self.with_context(dont_notify=True))._create_from_google(gevents, vals_list)
recurrence = super(CalendarRecurrence, self.with_context(dont_notify=True))._create_from_google(gevents, vals_list)
generic_values_creation = {
rec.id: attendee_values[rec.base_event_id.id]
for rec in recurrence if attendee_values.get(rec.base_event_id.id)
@ -197,7 +198,7 @@ class RecurrenceRule(models.Model):
# older versions of the module. When synced, these recurrency may come back from Google after database cleaning
# and trigger errors as the records are not properly populated.
# We also prevent sync of other user recurrent events.
return [('calendar_event_ids.user_id', '=', self.env.user.id), ('rrule', '!=', False)]
return Domain('calendar_event_ids.user_id', '=', self.env.user.id) & Domain('rrule', '!=', False)
@api.model
def _odoo_values(self, google_recurrence, default_reminders=()):
@ -239,3 +240,9 @@ class RecurrenceRule(models.Model):
if event:
return event._get_event_user()
return self.env.user
def _is_google_insertion_blocked(self, sender_user):
self.ensure_one()
has_base_event = self.base_event_id
has_different_owner = self.base_event_id.user_id and self.base_event_id.user_id != sender_user
return has_base_event and has_different_owner