Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] microsoft_outlook_multi_token #1537

Draft
wants to merge 1 commit into
base: 14.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 111 additions & 0 deletions microsoft_outlook_multi_token/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
=======================================
Multiple tokens for Outlook integration
=======================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:b9bfd85b383e14674d33e4c0cc7d43c30f417df20f405a0a6e4684b5143e9180
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
:target: https://odoo-community.org/page/development-status
:alt: Alpha
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github
:target: https://github.com/OCA/social/tree/14.0/microsoft_outlook_multi_token
:alt: OCA/social
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/social-14-0/social-14-0-microsoft_outlook_multi_token
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/social&target_branch=14.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows to configure client id and secret per server,
allowing to receive/send mail for different Azure tenants.

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.
`More details on development status <https://odoo-community.org/page/development-status>`_

**Table of contents**

.. contents::
:local:

Configuration
=============

To configure this module, you need to:

1. Go to Settings / Technical / Email / Outgoing Mail Servers or
Incoming Mail Servers
2. Fill in server specific client id/secret for servers that should have
it
3. Click ``Connect your Outlook account`` and finish the steps

Usage
=====

To use this module, you need to:

1. Create an incoming mail server with a custom client id and secret
2. Observe mails from this account are fetched as opposed to the account
configured globally

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/social/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/social/issues/new?body=module:%20microsoft_outlook_multi_token%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Hunki Enterprises BV

Contributors
------------

- Holger Brunn <[email protected]>
(https://hunki-enterprises.com)

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-hbrunn| image:: https://github.com/hbrunn.png?size=40px
:target: https://github.com/hbrunn
:alt: hbrunn

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-hbrunn|

This module is part of the `OCA/social <https://github.com/OCA/social/tree/14.0/microsoft_outlook_multi_token>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions microsoft_outlook_multi_token/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
22 changes: 22 additions & 0 deletions microsoft_outlook_multi_token/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2025 Hunki Enterprises BV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0)

{
"name": "Multiple tokens for Outlook integration",
"summary": "Allows to configure different client ids and secrets per server",
"version": "14.0.1.0.0",
"development_status": "Alpha",
"category": "Extra Tools",
"website": "https://github.com/OCA/social",
"author": "Hunki Enterprises BV, Odoo Community Association (OCA)",
"maintainers": ["hbrunn"],
"license": "AGPL-3",
"depends": [
"microsoft_outlook",
"fetchmail_outlook",
],
"data": [
"views/fetchmail_server.xml",
"views/ir_mail_server.xml",
],
}
2 changes: 2 additions & 0 deletions microsoft_outlook_multi_token/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import microsoft_outlook_mixin
from . import ir_config_parameter
19 changes: 19 additions & 0 deletions microsoft_outlook_multi_token/models/ir_config_parameter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2025 Hunki Enterprises BV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0)

from odoo import api, models


class IrConfigParameter(models.Model):
_inherit = "ir.config_parameter"

@api.model
def get_param(self, key, default=False):
multi_token_record = self.env.context.get("microsoft_outlook_multi_token")
if (
key in ("microsoft_outlook_client_id", "microsoft_outlook_client_secret")
and isinstance(multi_token_record, models.Model)
and multi_token_record.sudo()[key]
):
return multi_token_record.sudo()[key]
return super().get_param(key, default=default)
52 changes: 52 additions & 0 deletions microsoft_outlook_multi_token/models/microsoft_outlook_mixin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright 2025 Hunki Enterprises BV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0)

from odoo import api, fields, models


class MicrosoftOutlookMixin(models.AbstractModel):
_inherit = "microsoft.outlook.mixin"

microsoft_outlook_client_id = fields.Char(
string="Outlook Client ID",
help="If you want to use a different account than the globally "
"configured one, fill in its client id here",
groups="base.group_system",
copy=False,
)
microsoft_outlook_client_secret = fields.Char(
string="Outlook Client secret",
help="If you want to use a different account than the globally "
"configured one, fill in its client secret here",
groups="base.group_system",
copy=False,
)

@api.depends("microsoft_outlook_client_id", "microsoft_outlook_client_secret")
def _compute_is_microsoft_outlook_configured(self):
for this in self:
super(
MicrosoftOutlookMixin,
this.with_context(microsoft_outlook_multi_token=this),
)._compute_is_microsoft_outlook_configured()

def _compute_outlook_uri(self):
for this in self:
super(
MicrosoftOutlookMixin,
this.with_context(microsoft_outlook_multi_token=this),
)._compute_outlook_uri()

@api.onchange("microsoft_outlook_client_id", "microsoft_outlook_client_secret")
def _onchange_microsoft_outlook_multi_token(self):
self.update(
dict(
microsoft_outlook_refresh_token=False,
microsoft_outlook_access_token=False,
microsoft_outlook_access_token_expiration=False,
)
)

def _fetch_outlook_token(self, grant_type, **values):
self = self.with_context(microsoft_outlook_multi_token=self)
return super()._fetch_outlook_token(grant_type, **values)

Check warning on line 52 in microsoft_outlook_multi_token/models/microsoft_outlook_mixin.py

View check run for this annotation

Codecov / codecov/patch

microsoft_outlook_multi_token/models/microsoft_outlook_mixin.py#L51-L52

Added lines #L51 - L52 were not covered by tests
5 changes: 5 additions & 0 deletions microsoft_outlook_multi_token/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
To configure this module, you need to:

1. Go to Settings / Technical / Email / Outgoing Mail Servers or Incoming Mail Servers
2. Fill in server specific client id/secret for servers that should have it
3. Click ``Connect your Outlook account`` and finish the steps
1 change: 1 addition & 0 deletions microsoft_outlook_multi_token/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Holger Brunn \<[email protected]> (https://hunki-enterprises.com)
1 change: 1 addition & 0 deletions microsoft_outlook_multi_token/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module allows to configure client id and secret per server, allowing to receive/send mail for different Azure tenants.
4 changes: 4 additions & 0 deletions microsoft_outlook_multi_token/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
To use this module, you need to:

1. Create an incoming mail server with a custom client id and secret
2. Observe mails from this account are fetched as opposed to the account configured globally
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading