The following trick used to work, because `sudo()` was actually making an environment for the superuser to operate upon: request.env[...].sudo().method(...) It no longer works in general, since `sudo()` now makes an environment in superuser mode but with `uid=None`! It may still work by accident for operations that never use `env.uid`, but is broken in general. Using `auth='public'` fixes the problem by using the public user when no user is available. closes odoo/odoo#34297 Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
38 lines
1.5 KiB
Python
38 lines
1.5 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
import json
|
|
import logging
|
|
import pprint
|
|
import werkzeug
|
|
|
|
from odoo import http
|
|
from odoo.http import request
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
|
class AdyenController(http.Controller):
|
|
_return_url = '/payment/adyen/return/'
|
|
|
|
@http.route([
|
|
'/payment/adyen/return',
|
|
], type='http', auth='public', csrf=False)
|
|
def adyen_return(self, **post):
|
|
_logger.info('Beginning Adyen form_feedback with post data %s', pprint.pformat(post)) # debug
|
|
if post.get('authResult') not in ['CANCELLED']:
|
|
request.env['payment.transaction'].sudo().form_feedback(post, 'adyen')
|
|
return werkzeug.utils.redirect('/payment/process')
|
|
|
|
@http.route([
|
|
'/payment/adyen/notification',
|
|
], type='http', auth='public', methods=['POST'], csrf=False)
|
|
def adyen_notification(self, **post):
|
|
tx = post.get('merchantReference') and request.env['payment.transaction'].sudo().search([('reference', 'in', [post.get('merchantReference')])], limit=1)
|
|
if post.get('eventCode') in ['AUTHORISATION'] and tx:
|
|
states = (post.get('merchantReference'), post.get('success'), tx.state)
|
|
if (post.get('success') == 'true' and tx.state == 'done') or (post.get('success') == 'false' and tx.state in ['cancel', 'error']):
|
|
_logger.info('Notification from Adyen for the reference %s: received %s, state is %s', states)
|
|
else:
|
|
_logger.warning('Notification from Adyen for the reference %s: received %s but state is %s', states)
|
|
return '[accepted]'
|