Skip to content

Commit ee8e622

Browse files
authored
Merge pull request #53 from gisce/Alow_microsoft_graph
Add microsoft graph
2 parents 766578d + 2cecfd6 commit ee8e622

File tree

5 files changed

+63
-1
lines changed

5 files changed

+63
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# -*- coding: utf-8 -*-
2+
import logging
3+
import pooler
4+
5+
6+
def up(cursor, installed_version):
7+
if not installed_version:
8+
return
9+
10+
logger = logging.getLogger('openerp.migration')
11+
12+
logger.info("Creating pooler")
13+
pool = pooler.get_pool(cursor.dbname)
14+
15+
models = ["poweremail.core_accounts"]
16+
17+
for model in models:
18+
logger.info("Creating table: {}".format(model))
19+
pool.get(model)._auto_init(cursor, context={'module': 'poweremail_auth'})
20+
logger.info("Table created succesfully.")
21+
22+
23+
def down(cursor, installed_version):
24+
pass
25+
26+
27+
migrate = up
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# -*- coding: utf-8 -*-
2+
import logging
3+
from oopgrade.oopgrade import load_data_records
4+
5+
6+
def up(cursor, installed_version):
7+
if not installed_version:
8+
return
9+
10+
logger = logging.getLogger('openerp.migration')
11+
load_data_records(
12+
cursor, 'poweremail_auth',
13+
'poweremail_core_view.xml', ['view_poweremail_core_api_info_form'])
14+
logger.info('** XML VIEW UPDATED SUCCESSFULLY **')
15+
16+
17+
def down(cursor, installed_version):
18+
pass
19+
20+
21+
migrate = up

poweremail_auth/poweremail_core.py

+12
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,21 @@ def generate_oauth_2_string(self, username, access_token, base64_encode=True):
6161
auth_string = base64.b64encode(auth_string)
6262
return auth_string
6363

64+
def get_not_debug_sender(self, account):
65+
if account.microsoft_graph_login_id:
66+
from qreu.sendcontext import MicrosoftGraphSender
67+
return MicrosoftGraphSender(
68+
client_id=account.microsoft_graph_login_id.auth_api_id.client_id,
69+
client_secret=account.microsoft_graph_login_id.auth_api_id.client_secret,
70+
tenant_id=account.microsoft_graph_login_id.auth_api_id.acces_token_url.split('/')[-1],
71+
email_address=account.email_id
72+
)
73+
return super(PoweremailCoreAccounts, self).get_not_debug_sender(account)
74+
6475
_columns = {
6576
'smtp_auth_login_id': fields.many2one('poweremail.auth.login', 'Auth SMTP login ID'),
6677
'imap_auth_login_id': fields.many2one('poweremail.auth.login', 'Auth IMAP login ID'),
78+
'microsoft_graph_login_id': fields.many2one('poweremail.auth.login', 'Auth with graph.microsoft.com')
6779
}
6880

6981

poweremail_auth/poweremail_core_view.xml

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<page string="Api token">
1212
<field name="smtp_auth_login_id" colspan="4" select="1"/>
1313
<field name="imap_auth_login_id" colspan="4" select="1"/>
14+
<field name="microsoft_graph_login_id" colspan="4" select="1"/>
1415
</page>
1516
</page>
1617
</field>

poweremail_auth/requirements.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
msal
1+
msal
2+
qreu>=0.13.3

0 commit comments

Comments
 (0)