diff options
| author | Christophe Simonis <chs@odoo.com> | 2017-06-27 14:19:31 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2017-06-27 14:19:31 +0200 |
| commit | dd43071638773dcb58376b79ec7b1456c8b0454d (patch) | |
| tree | fd7935e2aa93de03fa3fe12507f8ef74405a255e /addons/payment/models | |
| parent | 6501184e6294ffb06e24a0ec8e9666b79a80b59a (diff) | |
| parent | 278e478d55209bd958836fde7fe1c82c555180dc (diff) | |
[MERGE] forward port branch saas-16 up to 278e478d552
Diffstat (limited to 'addons/payment/models')
| -rw-r--r-- | addons/payment/models/payment_acquirer.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/addons/payment/models/payment_acquirer.py b/addons/payment/models/payment_acquirer.py index bbb054a7a0b..2f3fc969458 100644 --- a/addons/payment/models/payment_acquirer.py +++ b/addons/payment/models/payment_acquirer.py @@ -527,7 +527,9 @@ class PaymentTransaction(models.Model): tx.write({'reference': str(tx.id)}) # Generate callback hash if it is configured on the tx; avoid generating unnecessary stuff - if tx.callback_model_id and tx.callback_res_id and tx.sudo().callback_method: + # (limited sudo env for checking callback presence, must work for manual transactions too) + tx_sudo = tx.sudo() + if tx_sudo.callback_model_id and tx_sudo.callback_res_id and tx_sudo.callback_method: tx.write({'callback_hash': tx._generate_callback_hash()}) return tx @@ -657,7 +659,13 @@ class PaymentTransaction(models.Model): @api.multi def execute_callback(self): res = None - for transaction in self.filtered(lambda tx: tx.callback_model_id and tx.callback_res_id and tx.sudo().callback_method): + for transaction in self: + # limited sudo env, only for checking callback presence, not for running it! + # manual transactions have no callback, and can pass without being run by admin user + tx_sudo = transaction.sudo() + if not (tx_sudo.callback_model_id and tx_sudo.callback_res_id and tx_sudo.callback_method): + continue + valid_token = transaction._generate_callback_hash() if not consteq(ustr(valid_token), transaction.callback_hash): _logger.warning("Invalid callback signature for transaction %d" % (transaction.id)) @@ -665,7 +673,7 @@ class PaymentTransaction(models.Model): record = self.env[transaction.callback_model_id.model].browse(transaction.callback_res_id).exists() if record: - res = getattr(record, transaction.sudo().callback_method)(transaction) + res = getattr(record, transaction.callback_method)(transaction) else: _logger.warning("Did not found record %s.%s for callback of transaction %d" % (transaction.callback_model_id.model, transaction.callback_res_id, transaction.id)) return res |
