Browse Source

Mar 29 : [UPDT] Updated 'onedrive_integration_odoo'

pull/370/head
AjmalCybro 4 weeks ago
parent
commit
5123e9c57f
  1. 2
      onedrive_integration_odoo/__manifest__.py
  2. 7
      onedrive_integration_odoo/doc/RELEASE_NOTES.md
  3. 67
      onedrive_integration_odoo/models/res_config_settings.py

2
onedrive_integration_odoo/__manifest__.py

@ -21,7 +21,7 @@
############################################################################### ###############################################################################
{ {
'name': "Onedrive Integration", 'name': "Onedrive Integration",
'version': "17.0.1.0.1", 'version': "17.0.1.0.2",
'category': "Productivity", 'category': "Productivity",
'summary': """Upload and download files in Onedrive using odoo """, 'summary': """Upload and download files in Onedrive using odoo """,
'description': """This module was developed to upload files to Onedrive as 'description': """This module was developed to upload files to Onedrive as

7
onedrive_integration_odoo/doc/RELEASE_NOTES.md

@ -7,4 +7,9 @@
#### 16.08.2024 #### 16.08.2024
#### Version 17.0.1.0.1 #### Version 17.0.1.0.1
#### UPDT #### UPDT
- Added modules field and changed view - Added modules field and changed view
#### 29.03.2025
#### Version 17.0.1.0.2
#### BUG FIX
- Added /consumers endpoint

67
onedrive_integration_odoo/models/res_config_settings.py

@ -81,36 +81,45 @@ class ResConfigSettings(models.TransientModel):
tenant_id = self.env['ir.config_parameter'].get_param( tenant_id = self.env['ir.config_parameter'].get_param(
'onedrive_integration_odoo.tenant_id', '') 'onedrive_integration_odoo.tenant_id', '')
res = requests.post( res = requests.post(
f"https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token", f"https://login.microsoftonline.com/common/oauth2/v2.0/token",
data=data, data=data,
headers={"content-type": "application/x-www-form-urlencoded"}) headers={"content-type": "application/x-www-form-urlencoded"})
response = res.content and res.json() or {} response = res.content and res.json() or {}
if 'error' in response: if 'error' in response:
raise UserError(_("Error '%s': Please check the credentials.", res = requests.post(
response['error'])) f"https://login.microsoftonline.com/consumers/oauth2/v2.0/token",
else: data=data,
authority = 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize' headers={"content-type": "application/x-www-form-urlencoded"})
action = self.env["ir.actions.client"].sudo()._for_xml_id( response = res.content and res.json() or {}
"onedrive_integration_odoo.onedrive_dashboard_action")
base_url = request.env['ir.config_parameter'].get_param( if 'error' in response:
'web.base.url') raise UserError(_("Error '%s': Please check the credentials.",
url_return = base_url + '/web#id=%d&action=%d&view_type=form&model=%s' \ response['error']))
% (self.id, action['id'], 'onedrive.dashboard')
encoded_params = urls.url_encode({
'response_type': 'code', authority = f'https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/authorize'
'client_id': self.env['ir.config_parameter'].get_param( action = self.env["ir.actions.client"].sudo()._for_xml_id(
'onedrive_integration_odoo.client_id', ''), "onedrive_integration_odoo.onedrive_dashboard_action")
'state': json.dumps({ base_url = request.env['ir.config_parameter'].get_param(
'onedrive_config_id': self.id, 'web.base.url')
'url_return': url_return url_return = base_url + '/web#id=%d&action=%d&view_type=form&model=%s' \
}), % (self.id, action['id'], 'onedrive.dashboard')
'scope': ['offline_access openid Files.ReadWrite.All'], encoded_params = urls.url_encode({
'redirect_uri': base_url + '/onedrive/authentication', 'response_type': 'code',
'prompt': 'consent', 'client_id': self.env['ir.config_parameter'].get_param(
'access_type': 'offline' 'onedrive_integration_odoo.client_id', ''),
}) 'state': json.dumps({
return { 'onedrive_config_id': self.id,
'type': 'ir.actions.act_url', 'url_return': url_return
'target': 'self', }),
'url': "%s?%s" % (authority, encoded_params), 'scope': ['offline_access openid Files.ReadWrite.All'],
} 'redirect_uri': base_url + '/onedrive/authentication',
'prompt': 'consent',
'access_type': 'offline'
})
return {
'type': 'ir.actions.act_url',
'target': 'self',
'url': "%s?%s" % (authority, encoded_params),
}

Loading…
Cancel
Save