[IMP] microsoft_outlook: allow customizing the outlook endpoint

Purpose
=======
If we want to deploy Outlook for a custom organization, it might be
useful to be able to customize the endpoint used in the API request.

For that purpose, we added a system parameter to overwrite the default
endpoint.

Task-2811567

Part-of: odoo/odoo#88215
This commit is contained in:
std-odoo
2022-07-12 15:36:50 +02:00
parent eb2dd1d674
commit afe8222712
@@ -47,13 +47,14 @@ class MicrosoftOutlookMixin(models.AbstractModel):
Config = self.env['ir.config_parameter'].sudo()
base_url = self.get_base_url()
microsoft_outlook_client_id = Config.get_param('microsoft_outlook_client_id')
OUTLOOK_ENDPOINT = Config.get_param('microsoft.outlook.endpoint', self._OUTLOOK_ENDPOINT)
for record in self:
if not record.id or not record.use_microsoft_outlook_service or not record.is_microsoft_outlook_configured:
record.microsoft_outlook_uri = False
continue
record.microsoft_outlook_uri = url_join(self._OUTLOOK_ENDPOINT, 'authorize?%s' % url_encode({
record.microsoft_outlook_uri = url_join(OUTLOOK_ENDPOINT, 'authorize?%s' % url_encode({
'client_id': microsoft_outlook_client_id,
'response_type': 'code',
'redirect_uri': url_join(base_url, '/microsoft_outlook/confirm'),
@@ -124,9 +125,10 @@ class MicrosoftOutlookMixin(models.AbstractModel):
base_url = self.get_base_url()
microsoft_outlook_client_id = Config.get_param('microsoft_outlook_client_id')
microsoft_outlook_client_secret = Config.get_param('microsoft_outlook_client_secret')
OUTLOOK_ENDPOINT = Config.get_param('microsoft.outlook.endpoint', self._OUTLOOK_ENDPOINT)
response = requests.post(
url_join(self._OUTLOOK_ENDPOINT, 'token'),
url_join(OUTLOOK_ENDPOINT, 'token'),
data={
'client_id': microsoft_outlook_client_id,
'client_secret': microsoft_outlook_client_secret,