[FIX] hr_holidays, *_calendar: disable sync on new leave

On large databases, the `postcommit` hook for Google|Microsoft Calendar
was taking up to 10% of a leave validation even if the user has the sync
disabled.

This commit disables the postcommit hook for new leaves, as the event will
be synced through the cron eventually.

closes odoo/odoo#80160

Taskid: 2693265
X-original-commit: 88884292e105eab2c36b2a334c617ac4978fa79c
Signed-off-by: Arnaud Joset <arj@odoo.com>
Signed-off-by: Kevin Baptiste <kba@odoo.com>
This commit is contained in:
Kevin Baptiste
2021-11-22 11:56:46 +00:00
parent 54b45aec9e
commit b90ee11ef3
3 changed files with 7 additions and 0 deletions
@@ -31,6 +31,9 @@ def after_commit(func):
context = self.env.context
uid = self.env.uid
if self.env.context.get('no_calendar_sync'):
return
@self.env.cr.postcommit.add
def called_after():
db_registry = registry(dbname)
+1
View File
@@ -1230,6 +1230,7 @@ class HolidaysRequest(models.Model):
tracking_disable=True,
mail_activity_automation_skip=True,
leave_fast_create=True,
no_calendar_sync=True,
leave_skip_state_check=True,
).create(values)
@@ -33,6 +33,9 @@ def after_commit(func):
context = self.env.context
uid = self.env.uid
if self.env.context.get('no_calendar_sync'):
return
@self.env.cr.postcommit.add
def called_after():
db_registry = registry(dbname)