[IMP] calendar: add synchronization pause buttons

Configuration added for 'pause synchronization' buttons (Google and Outlook).

Task-id: 3290898
Part-of: odoo/odoo#126560
This commit is contained in:
Gabriel de Paula Felix (gdpf)
2023-08-21 12:38:42 +02:00
parent 6caa9f5095
commit c8f2fa1e6d
2 changed files with 11 additions and 0 deletions
@@ -3,6 +3,7 @@
from odoo import fields, models
from odoo.addons.base.models.ir_module import assert_log_admin_access
from odoo.tools import str2bool
class CalendarProviderConfig(models.TransientModel):
@@ -21,12 +22,18 @@ class CalendarProviderConfig(models.TransientModel):
cal_client_secret = fields.Char(
"Google Client_key",
default=lambda self: self.env['ir.config_parameter'].get_param('google_calendar_client_secret'))
cal_sync_paused = fields.Boolean(
"Google Synchronization Paused",
default=lambda self: str2bool(self.env['ir.config_parameter'].get_param('google_calendar_sync_paused'), default=False))
microsoft_outlook_client_identifier = fields.Char(
"Outlook Client Id",
default=lambda self: self.env['ir.config_parameter'].get_param('microsoft_calendar_client_id'))
microsoft_outlook_client_secret = fields.Char(
"Outlook Client Secret",
default=lambda self: self.env['ir.config_parameter'].get_param('microsoft_calendar_client_secret'))
microsoft_outlook_sync_paused = fields.Boolean(
"Outlook Synchronization Paused",
default=lambda self: str2bool(self.env['ir.config_parameter'].get_param('microsoft_calendar_sync_paused'), default=False))
@assert_log_admin_access
def action_calendar_prepare_external_provider_sync(self):
@@ -45,6 +52,8 @@ class CalendarProviderConfig(models.TransientModel):
if self.external_calendar_provider == 'google':
self.env['ir.config_parameter'].set_param('google_calendar_client_id', self.cal_client_id)
self.env['ir.config_parameter'].set_param('google_calendar_client_secret', self.cal_client_secret)
self.env['ir.config_parameter'].set_param('google_calendar_sync_paused', self.cal_sync_paused)
elif self.external_calendar_provider == 'microsoft':
self.env['ir.config_parameter'].set_param('microsoft_calendar_client_id', self.microsoft_outlook_client_identifier)
self.env['ir.config_parameter'].set_param('microsoft_calendar_client_secret', self.microsoft_outlook_client_secret)
self.env['ir.config_parameter'].set_param('microsoft_calendar_sync_paused', self.microsoft_outlook_sync_paused)
@@ -16,6 +16,7 @@
<group>
<field name="cal_client_id" string="Client ID" required="external_calendar_provider == 'google'"/>
<field name="cal_client_secret" string="Client Secret" password="True" required="external_calendar_provider == 'google'"/>
<field name="cal_sync_paused" required="external_calendar_provider == 'google'"/>
</group>
</div>
<div invisible="external_calendar_provider != 'microsoft'">
@@ -28,6 +29,7 @@
<group>
<field name="microsoft_outlook_client_identifier" string="Client ID" required="external_calendar_provider == 'microsoft'"/>
<field name="microsoft_outlook_client_secret" string="Client Secret" password="True" required="external_calendar_provider == 'microsoft'"/>
<field name="microsoft_outlook_sync_paused" required="external_calendar_provider == 'microsoft'"/>
</group>
</div>
<footer>