Skip to content

Commit 568c9c5

Browse files
authored
Merge pull request #3631 from ForgeFlow/12.0-update-upstream-c53081f10be
[12.0] update upstream c53081f
2 parents c405b58 + 49fb113 commit 568c9c5

10 files changed

Lines changed: 512 additions & 77 deletions

File tree

addons/calendar/models/calendar.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,10 +1254,10 @@ def boolean_product(x):
12541254
for name, desc in sort_spec
12551255
)
12561256
# then Reverse if the value matches a "desc" column
1257-
return [
1257+
return tuple(
12581258
(tools.Reverse(v) if desc else v)
12591259
for v, desc in vals_spec
1260-
]
1260+
)
12611261
return [r['id'] for r in sorted(result_data, key=key)]
12621262

12631263
@api.multi
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * fetchmail_gmail
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 12.0+e\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"POT-Creation-Date: 2022-05-13 06:43+0000\n"
10+
"PO-Revision-Date: 2022-05-13 06:43+0000\n"
11+
"Last-Translator: <>\n"
12+
"Language-Team: \n"
13+
"MIME-Version: 1.0\n"
14+
"Content-Type: text/plain; charset=UTF-8\n"
15+
"Content-Transfer-Encoding: \n"
16+
"Plural-Forms: \n"
17+
18+
#. module: fetchmail_gmail
19+
#: model_terms:ir.ui.view,arch_db:fetchmail_gmail.fetchmail_server_view_form
20+
msgid "Authorization Code"
21+
msgstr ""
22+
23+
#. module: fetchmail_gmail
24+
#: model_terms:ir.ui.view,arch_db:fetchmail_gmail.fetchmail_server_view_form
25+
msgid "Gmail"
26+
msgstr ""
27+
28+
#. module: fetchmail_gmail
29+
#: code:addons/fetchmail_gmail/models/fetchmail_server.py:15
30+
#, python-format
31+
msgid "Gmail authentication only supports IMAP server type."
32+
msgstr ""
33+
34+
#. module: fetchmail_gmail
35+
#: model:ir.model,name:fetchmail_gmail.model_fetchmail_server
36+
msgid "Incoming Mail Server"
37+
msgstr ""
38+
39+
#. module: fetchmail_gmail
40+
#: model_terms:ir.ui.view,arch_db:fetchmail_gmail.fetchmail_server_view_form
41+
msgid "Setup your Gmail API credentials in the general settings to link a Gmail account."
42+
msgstr ""
43+

addons/fetchmail_gmail/views/fetchmail_server_views.xml

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,30 @@
1010
<field name="use_google_gmail_service" string="Gmail" attrs="{'readonly': [('state', '=', 'done')]}"/>
1111
</field>
1212
<field name="user" position="after">
13-
<field string="Authorization Code" name="google_gmail_authorization_code" password="True"
14-
attrs="{'required': [('use_google_gmail_service', '=', True)], 'invisible': [('use_google_gmail_service', '=', False)], 'readonly': [('state', '=', 'done')]}"
15-
style="word-break: break-word;"/>
16-
<field name="google_gmail_uri"
17-
class="fa fa-arrow-right oe_edit_only"
18-
widget="url"
19-
text=" Get an Authorization Code"
20-
attrs="{'invisible': ['|', ('use_google_gmail_service', '=', False), ('google_gmail_uri', '=', False)]}"
21-
nolabel="1"/>
22-
<div class="alert alert-warning" role="alert"
23-
attrs="{'invisible': ['|', ('use_google_gmail_service', '=', False), ('google_gmail_uri', '!=', False)]}">
24-
Setup your Gmail API credentials in the general settings to link a Gmail account.
13+
<field name="google_gmail_uri" invisible="1"/>
14+
<field name="google_gmail_refresh_token" invisible="1"/>
15+
<div></div>
16+
<div attrs="{'invisible': [('use_google_gmail_service', '=', False)]}">
17+
<span attrs="{'invisible': ['|', ('use_google_gmail_service', '=', False), ('google_gmail_refresh_token', '=', False)]}"
18+
class="badge badge-success">
19+
Gmail Token Valid
20+
</span>
21+
<button type="object"
22+
name="open_google_gmail_uri" class="btn-link px-0"
23+
attrs="{'invisible': ['|', '|', ('google_gmail_uri', '=', False), ('use_google_gmail_service', '=', False), ('google_gmail_refresh_token', '!=', False)]}">
24+
<i class="fa fa-arrow-right"/>
25+
Connect your Gmail account
26+
</button>
27+
<button type="object"
28+
name="open_google_gmail_uri" class="btn-link px-0"
29+
attrs="{'invisible': ['|', '|', ('google_gmail_uri', '=', False), ('use_google_gmail_service', '=', False), ('google_gmail_refresh_token', '=', False)]}">
30+
<i class="fa fa-cog"/>
31+
Edit Settings
32+
</button>
33+
<div class="alert alert-warning" role="alert"
34+
attrs="{'invisible': ['|', ('use_google_gmail_service', '=', False), ('google_gmail_uri', '!=', False)]}">
35+
Setup your Gmail API credentials in the general settings to link a Gmail account.
36+
</div>
2537
</div>
2638
</field>
2739
<field name="password" position="attributes">

addons/google_gmail/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# -*- coding: utf-8 -*-
22
# Part of Odoo. See LICENSE file for full copyright and licensing details.
33

4+
from . import controllers
45
from . import models
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# -*- coding: utf-8 -*
2+
# Part of Odoo. See LICENSE file for full copyright and licensing details.
3+
4+
from . import main
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# -*- coding: utf-8 -*-
2+
# Part of Odoo. See LICENSE file for full copyright and licensing details.
3+
4+
import json
5+
import logging
6+
import werkzeug
7+
8+
from werkzeug.exceptions import Forbidden
9+
from werkzeug.urls import url_encode
10+
11+
from odoo import _, http
12+
from odoo.exceptions import UserError
13+
from odoo.http import request
14+
from odoo.tools import consteq
15+
16+
_logger = logging.getLogger(__name__)
17+
18+
19+
class GoogleGmailController(http.Controller):
20+
@http.route('/google_gmail/confirm', type='http', auth='user')
21+
def google_gmail_callback(self, code=None, state=None, error=None, **kwargs):
22+
"""Callback URL during the OAuth process.
23+
24+
Gmail redirects the user browser to this endpoint with the authorization code.
25+
We will fetch the refresh token and the access token thanks to this authorization
26+
code and save those values on the given mail server.
27+
"""
28+
if not request.env.user.has_group('base.group_system'):
29+
_logger.error('Google Gmail: non-system user trying to link an Gmail account.')
30+
raise Forbidden()
31+
32+
if error:
33+
return _('An error occur during the authentication process: %s.') % error
34+
35+
try:
36+
state = json.loads(state)
37+
model_name = state['model']
38+
rec_id = state['id']
39+
csrf_token = state['csrf_token']
40+
except Exception:
41+
_logger.error('Google Gmail: Wrong state value %r.', state)
42+
raise Forbidden()
43+
44+
model = request.env[model_name]
45+
46+
if not issubclass(type(model), request.env.registry['google.gmail.mixin']):
47+
# The model must inherits from the "google.gmail.mixin" mixin
48+
raise Forbidden()
49+
50+
record = model.browse(rec_id).exists()
51+
if not record:
52+
raise Forbidden()
53+
54+
if not csrf_token or not consteq(csrf_token, record._get_gmail_csrf_token()):
55+
_logger.error('Google Gmail: Wrong CSRF token during Gmail authentication.')
56+
raise Forbidden()
57+
58+
try:
59+
refresh_token, access_token, expiration = record._fetch_gmail_refresh_token(code)
60+
except UserError as e:
61+
return _('An error occur during the authentication process: %s.') % str(e.name)
62+
63+
record.write({
64+
'google_gmail_access_token': access_token,
65+
'google_gmail_access_token_expiration': expiration,
66+
'google_gmail_authorization_code': code,
67+
'google_gmail_refresh_token': refresh_token,
68+
})
69+
70+
url_params = {
71+
'id': rec_id,
72+
'model': model_name,
73+
'view_type': 'form'
74+
}
75+
url = '/web?#' + url_encode(url_params)
76+
return werkzeug.utils.redirect(url, 303)
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * google_gmail
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 12.0+e\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"POT-Creation-Date: 2022-05-13 06:43+0000\n"
10+
"PO-Revision-Date: 2022-05-13 06:43+0000\n"
11+
"Last-Translator: <>\n"
12+
"Language-Team: \n"
13+
"MIME-Version: 1.0\n"
14+
"Content-Type: text/plain; charset=UTF-8\n"
15+
"Content-Transfer-Encoding: \n"
16+
"Plural-Forms: \n"
17+
18+
#. module: google_gmail
19+
#: model_terms:ir.ui.view,arch_db:google_gmail.res_config_settings_view_form
20+
msgid "<span class=\"o_form_label\">Gmail Credentials</span>"
21+
msgstr ""
22+
23+
#. module: google_gmail
24+
#: model:ir.model.fields,field_description:google_gmail.field_google_gmail_mixin__google_gmail_access_token
25+
#: model:ir.model.fields,field_description:google_gmail.field_ir_mail_server__google_gmail_access_token
26+
msgid "Access Token"
27+
msgstr ""
28+
29+
#. module: google_gmail
30+
#: model:ir.model.fields,field_description:google_gmail.field_google_gmail_mixin__google_gmail_access_token_expiration
31+
#: model:ir.model.fields,field_description:google_gmail.field_ir_mail_server__google_gmail_access_token_expiration
32+
msgid "Access Token Expiration Timestamp"
33+
msgstr ""
34+
35+
#. module: google_gmail
36+
#: code:addons/google_gmail/controllers/main.py:33
37+
#, python-format
38+
msgid "An error occur during the authentication process: %s."
39+
msgstr ""
40+
41+
#. module: google_gmail
42+
#: code:addons/google_gmail/models/google_gmail_mixin.py:136
43+
#, python-format
44+
msgid "An error occurred when fetching the access token."
45+
msgstr ""
46+
47+
#. module: google_gmail
48+
#: model:ir.model.fields,field_description:google_gmail.field_google_gmail_mixin__google_gmail_authorization_code
49+
#: model:ir.model.fields,field_description:google_gmail.field_ir_mail_server__google_gmail_authorization_code
50+
#: model_terms:ir.ui.view,arch_db:google_gmail.ir_mail_server_view_form
51+
msgid "Authorization Code"
52+
msgstr ""
53+
54+
#. module: google_gmail
55+
#: model_terms:ir.ui.view,arch_db:google_gmail.res_config_settings_view_form
56+
msgid "Client ID"
57+
msgstr ""
58+
59+
#. module: google_gmail
60+
#: model_terms:ir.ui.view,arch_db:google_gmail.res_config_settings_view_form
61+
msgid "Client Secret"
62+
msgstr ""
63+
64+
#. module: google_gmail
65+
#: model:ir.model,name:google_gmail.model_res_config_settings
66+
msgid "Config Settings"
67+
msgstr ""
68+
69+
#. module: google_gmail
70+
#: model:ir.model.fields,field_description:google_gmail.field_google_gmail_mixin__display_name
71+
msgid "Display Name"
72+
msgstr ""
73+
74+
#. module: google_gmail
75+
#: model_terms:ir.ui.view,arch_db:google_gmail.ir_mail_server_view_form
76+
msgid "Gmail"
77+
msgstr ""
78+
79+
#. module: google_gmail
80+
#: model:ir.model.fields,field_description:google_gmail.field_google_gmail_mixin__use_google_gmail_service
81+
#: model:ir.model.fields,field_description:google_gmail.field_ir_mail_server__use_google_gmail_service
82+
msgid "Gmail Authentication"
83+
msgstr ""
84+
85+
#. module: google_gmail
86+
#: model:ir.model.fields,field_description:google_gmail.field_res_config_settings__google_gmail_client_identifier
87+
msgid "Gmail Client Id"
88+
msgstr ""
89+
90+
#. module: google_gmail
91+
#: model:ir.model.fields,field_description:google_gmail.field_res_config_settings__google_gmail_client_secret
92+
msgid "Gmail Client Secret"
93+
msgstr ""
94+
95+
#. module: google_gmail
96+
#: model:ir.model,name:google_gmail.model_google_gmail_mixin
97+
msgid "Google Gmail Mixin"
98+
msgstr ""
99+
100+
#. module: google_gmail
101+
#: model:ir.model.fields,field_description:google_gmail.field_google_gmail_mixin__id
102+
msgid "ID"
103+
msgstr ""
104+
105+
#. module: google_gmail
106+
#: model:ir.model.fields,field_description:google_gmail.field_google_gmail_mixin____last_update
107+
msgid "Last Modified on"
108+
msgstr ""
109+
110+
#. module: google_gmail
111+
#: model:ir.model,name:google_gmail.model_ir_mail_server
112+
msgid "Mail Server"
113+
msgstr ""
114+
115+
#. module: google_gmail
116+
#: code:addons/google_gmail/models/google_gmail_mixin.py:72
117+
#, python-format
118+
msgid "Only the administrator can link a Gmail mail server."
119+
msgstr ""
120+
121+
#. module: google_gmail
122+
#: code:addons/google_gmail/models/google_gmail_mixin.py:75
123+
#, python-format
124+
msgid "Please configure your Gmail credentials."
125+
msgstr ""
126+
127+
#. module: google_gmail
128+
#: model:ir.model.fields,field_description:google_gmail.field_google_gmail_mixin__google_gmail_refresh_token
129+
#: model:ir.model.fields,field_description:google_gmail.field_ir_mail_server__google_gmail_refresh_token
130+
msgid "Refresh Token"
131+
msgstr ""
132+
133+
#. module: google_gmail
134+
#: model_terms:ir.ui.view,arch_db:google_gmail.res_config_settings_view_form
135+
msgid "Send and receive email with your Gmail account."
136+
msgstr ""
137+
138+
#. module: google_gmail
139+
#: model_terms:ir.ui.view,arch_db:google_gmail.ir_mail_server_view_form
140+
msgid "Setup your Gmail API credentials in the general settings to link a Gmail account."
141+
msgstr ""
142+
143+
#. module: google_gmail
144+
#: model:ir.model.fields,help:google_gmail.field_google_gmail_mixin__google_gmail_uri
145+
#: model:ir.model.fields,help:google_gmail.field_ir_mail_server__google_gmail_uri
146+
msgid "The URL to generate the authorization code from Google"
147+
msgstr ""
148+
149+
#. module: google_gmail
150+
#: model:ir.model.fields,field_description:google_gmail.field_google_gmail_mixin__google_gmail_uri
151+
#: model:ir.model.fields,field_description:google_gmail.field_ir_mail_server__google_gmail_uri
152+
msgid "URI"
153+
msgstr ""
154+

0 commit comments

Comments
 (0)