Files
odoo_source/addons/mail_plugin/models/ir_http.py
T
std-odoo 24cf7bdc35 [FIX] mail_plugin: use the user language in context
Bug
===
When searching for projects from the Outlook / Gmail addins, the names
were not translated into the user's language.

Task-3486324

closes odoo/odoo#136645

X-original-commit: 7ebe04189c84381e133ad3d0d6f8b97832b28a14
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Signed-off-by: Stéphane Debauche (std) <std@odoo.com>
2023-09-28 01:51:23 +00:00

30 lines
947 B
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from werkzeug.exceptions import BadRequest
from odoo import models
from odoo.http import request
class IrHttp(models.AbstractModel):
_inherit = 'ir.http'
@classmethod
def _auth_method_outlook(cls):
access_token = request.httprequest.headers.get('Authorization')
if not access_token:
raise BadRequest('Access token missing')
if access_token.startswith('Bearer '):
access_token = access_token[7:]
user_id = request.env["res.users.apikeys"]._check_credentials(scope='odoo.plugin.outlook', key=access_token)
if not user_id:
raise BadRequest('Access token invalid')
# take the identity of the API key user
request.update_env(user=user_id)
# switch to the user context
request.update_context(**request.env.user.context_get())