diff options
| author | Toufik Ben Jaa <tbe@odoo.com> | 2018-12-06 14:09:24 +0000 |
|---|---|---|
| committer | Toufik Ben Jaa <tbe@odoo.com> | 2018-12-06 14:09:24 +0000 |
| commit | 84b976fb7c5f521549315b7b9c038e79f59f8eec (patch) | |
| tree | 65f60f9f160907ebf6f56eb2bf0e8595c05ab9ce /addons | |
| parent | 89d3e2219ce9393c69d71b2e97c2b12faa07a2cb (diff) | |
[FIX] payment: process payments older than 10 minutes
- The payment transaction processing cron retrieves all the transactions
that need to be processed.
In some cases, it can causes issues when trying to process payments
that are being process by the payment polling page after returning
from the payment acquirer.
To avoid this concurrency issues, the cron will only process payments
that have been validated for at least 10 minutes.
closes odoo/odoo#29317
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/payment/models/payment_acquirer.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/addons/payment/models/payment_acquirer.py b/addons/payment/models/payment_acquirer.py index 90d9177ff58..9fa51724678 100644 --- a/addons/payment/models/payment_acquirer.py +++ b/addons/payment/models/payment_acquirer.py @@ -4,6 +4,7 @@ import hashlib import hmac import logging from datetime import datetime +from dateutil import relativedelta import pprint from odoo import api, exceptions, fields, models, _ @@ -783,9 +784,11 @@ class PaymentTransaction(models.Model): @api.multi def _cron_post_process_after_done(self): if not self: + ten_minutes_ago = datetime.now() - relativedelta.relativedelta(minutes=10) # we retrieve all the payment tx that need to be post processed self = self.search([('state', '=', 'done'), - ('is_processed', '=', False) + ('is_processed', '=', False), + ('date', '<=', ten_minutes_ago), ]) for tx in self: try: |
