OneDrive / SharePoint Odoo Integrationby Odoo Tools
Odoo document system is clear and comfortable to use. However, it is not designed to work with files as OneDrive does. To process attachments users need to download a file, to change it, and to upload back. Documents are not synced locally and Odoo doesn't have powerful previewers and editors like Word or Excel. OneDrive doesn't have such disadvantages. This is the tool to integrate OneDrive features into your Odoo business work flow. The app automatically stores all Odoo attachments in OneDrive and provides an instant access to them via web links. In such a way users work with files comfortably in OneDrive, while the results are fully available in Odoo.
The tool is compatible with both Odoo Enterprise and Odoo Community.
- Prepare and keep updated folders' structure in OneDrive
- Upload new attachments to a correct folder
Odoo creates a convenient directory structure in OneDrive: Odoo / Document type name / Document name / Files, where:
- Odoo is a central directory for Odoo Sync in your Drive.
- Document type is a synced Odoo model, for example, 'Sale orders', 'Opportunities', 'Customers'
- You select document types by yourself. It might be any document type
- Moreover, you might have a few folders for a single document type. Use Odoo domains to have not global 'Partners, but 'Customers' and 'Suppliers', not just 'Sale orders' but 'Commercial offers', 'To deliver', and 'Done orders'
- With each sync Odoo would try to update document types' folders. Add a new document type at any moment. It will appear in OneDrive with a next sync
- You are welcome to introduce or change document types folder names at any moment in Odoo. Take into account: renaming in OneDrive will be recovered to Odoo names
- If you remove a model from integration, it will not be deleted from OneDrive to keep already synced files safe. However, new documents of this type would not be synced
- In case you removed a directory in OneDrive / SharePoint, but it is still configured in Odoo, with a next sync a folder structure is going to be recovered (not files, surely).
- Document is an exact object to sync. For instance, 'Agrolait' or 'SO019'
- Documents are synced in case they relate to a synced document type and satisfy its filters. For example, you are not obliged to sync all partners, you may integrate only 'Customers' and 'Vendors' or only 'Companies', not 'Contacts'
- Odoo would generate a folder in OneDrive for each suitable document even for documents without attachments. It is needed for a backward sync to easily add new files
- OneDrive folder name equals a real document name. It relies upon Odoo name_get method. Thus, Odoo 'Michael Fletcher' (a contact of 'Agrolait') would be OneDrive 'Agrolait, Michael Fletcher'
- If an exact document changes its document type (e.g. a quotation is now confirmed), Odoo will automatically relocate its related folder to a proper parent directory (in the example: from 'Commercial offers' to 'To deliver')
- In case a document relates to a few types (for instance, you have 'Vendors' and 'Customers', while Agrolait is both), this document folder would be put into the most prioritized document type. A document type priority is higher as closer to the top in Odoo interfaces it is
- If an Odoo document is removed, the next sync will remove a corresponding OneDrive directory
- In case you remove a directory in OneDrive / SharePoint, but it still exists in Odoo, OneDrive folder structure would be recovered (while files would be unlinked in both Odoo and OneDrive)
- Folders renaming in OneDrive will be replaced with Odoo names, Odoo document names are more important
- Files are real files taken from Odoo attachments
The resulted path would be, for example, 'Odoo / Quotations / SO019 / commercial offer.png'.
The only exclusion of the rule are stand alone attachments which do not relate to any Odoo documents (their document type is 'ir.attachment'). Such attachments' path is 'Odoo / Stand Alone Attachments / image.png'.
The very first sync might take quite a long, since a lot of folders should be created. Afterwards, it would be much faster. However, it is not recommended to make sync too frequent: once an hour seems quite good for large files.Files
With each direct sync, Odoo tries to find not yet synced attachments. If such attachments suit any document type to sync, a file will be uploaded to OneDrive to a proper folder. In Odoo such attachments will become of 'url' type. It means that a file is not any more kept in Odoo server space, but now it is in OneDrive. Until sync is done, Odoo attachment remains binary and stores an actual file. Such approach helps Odoo to work faster.
Clicking on such attachment leads you to a file previewer / editor in OneDrive. Depending on your OneDrive / SharePoint configurations it might be Word, Excel, PDF previewer, etc. Anyway changes to file contents in OneDrive are available in Odoo at the same moment.
If you unlinked an attachment from Odoo, it would be deleted in OneDrive as well.
Take into account that file names should be managed in OneDrive: each backward sync would recover OneDrive names, Odoo is here less important.
- If a new file is added to a proper document folder (e.g. to 'Odoo / Customers / Agrolait'), the same attachment will be added to Odoo document (in the example – to 'Agrolait')
- In document folders you can put not only files but also child folders. In that case a link for this folder (not its content) is kept in attachments
- In case you rename a file in OneDrive, it will be renamed in Odoo as well
- Files' removal from OneDrive leads to related Odoo attachments' removal
- If you move a file to another document folder, in Odoo a related attachment would be re-attached to this new document. Take into account: if you move a file for a not document folder, in Odoo attachment will be deleted as it has been removed from OneDrive
- If you deleted a document type or document folder, their child files are deleted as well. Thus, Odoo would remove related attachments. The folders, however, will be recovered with a next direct sync. Folders' move to another directory is also considered as a removal. Avoid such situations by following the simple rule: folders are managed mostly by Odoo, files – mostly by OneDrive.
Backward OneDrive sync might take time. It is recommended to make frequency oftener than once an hour or two hours.
This tool is not in conflict with the 'documents' module provided by the Enterprise license. Attachments related to Enterprise folders would be synced as any other files: according to a document they relate to. In the most cases it means they would be linked to stand-alone attachments.
It is not always comfortable, and you might be interested in reflecting directories' structure introduced by the module 'Documents'. To this end the extension Cloud Sync for Enterprise Documents (its standard price is 44 Euros) is developed. This tool has the following features:
- The documents hierarchy is reflected within the folder 'Odoo / Odoo Docs'
- Each Odoo folder has a linked cloud folder. Take into account that folders created in the cloud storage will be synced as Odoo attachments. The key principle is: folders are managed by Odoo, files are managed by the cloud client
- All files are synced with the same logic as usual attachments. Files created in Odoo will be added to the cloud storage and will be replaced with links in Odoo. Files created in cloud storage will generate attachments within a paired directory
- Please do not name synced models as 'Odoo Docs'. This is the reserved name for Odoo Enterprise Documents
pip install microsoftgraph-python
- Go to your Azure Portal and prepare a new application:
- Grant the app full permissions for Office365 SharePoint online
- Assign the reply url as [YOURODOOSITENAME]/one_drive_token (e.g. https://odootools.com/one_drive_token)
- Generate a new key. Keep it safely somewhere for the future use
- Go to your SharePoint site and prepare a new documents' library (drive). You might use one of the existing ones, e.g. 'Documents'. Odoo folder would be put there afterwards, and it would be impossible to move it for another library
- Go to Odoo general settings > Onedrive.
- Copy 'Application ID' to 'App client_id'
- Put a previously generated key to the field 'App secret key'
- Enter the 'Redirect URL' as you entered 'Reply url' in Azure Portal
- Check the boxes 'OneDrive for business' and 'Use sharepoint sites'
- The SharePoint URL should be of the type https://[URL]/. The last '/' is required, sitename should not be included into. For example, https://odootools.sharepoint.com/
- SharePoint site should be either my_site_name (in that case it is considered as sites/my_site_name) or sites/my_site_name (instead of 'sites' it might be 'teams' and so on). There should be no '/' at the beginning or at the end. For example, sites/odootools
- As Documents Library use one created in SharePoint
- Press 'Save'
- Press 'Login and Confirm'. Odoo redirects you to Microsoft login page. Check in and grant permissions asked.
- After login, Microsoft redirects you back to Odoo. OneDrive – Odoo synchronization is ready to be done.
- Go to https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationsListBlade
- Click 'New registration'
- Introduce a new name for the application and assign the redirect URI as [YOURODOOSITENAME]/one_drive_token (e.g. https://odootools.com/one_drive_token)
- Copy the Application Client ID to the Odoo field 'App client_id'
- Go to Certificates & secrets > Click 'New Client Secret'. Copy the secret value to the Odoo field 'App Secret Key'
- Press Save on the Odoo configuration Page
- Press 'Login and Confirm'. Odoo redirects you to Microsoft login page. Check in and grant permissions asked
- After login, Microsoft redirects you back to Odoo. OneDrive – Odoo synchronization is ready to be done.
- Press the button 'Reconnect'
- Press the button 'Login and confirm'
OdooTools is the team of developers and business analysts to help you extend Odoo potential. We have been communicating with end users to whom the software became the main business tool since 2012. As a result, we are proud of dozens of successful Odoo apps developed. We are open for new ideas and challenges to create the best Odoo tools for business needs all over the world.
This tool has been developed in cooperation with IT Libertas - one of the leading Odoo integrators in Russia.
Odoo Proprietary License v1.0 This software and associated files (the "Software") may only be used (executed, modified, executed after modifications) if you have purchased a valid license from the authors, typically via Odoo Apps, or if you have received a written agreement from the authors of the Software (see the COPYRIGHT file). You may develop Odoo modules that use the Software as a library (typically by depending on it, importing it and using its resources), but without copying any source code or material from the Software. You may distribute those modules under the license of your choice, provided that this license is compatible with the terms of the Odoo Proprietary License (For example: LGPL, MIT, or proprietary licenses similar to this one). It is forbidden to publish, distribute, sublicense, or sell copies of the Software or modified copies of the Software. The above copyright notice and this permission notice must be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.