[FIX] payment: do not retry indefinitely to post process transactions
Suppose that a payment transaction cannot be reconciled for any reason. Then _cron_post_process_after_done will try to process it every 10 minutes until the end of time. Moreover, if the user takes some manual action before _cron_post_process_after_done, even if in principle it would have been able to go through, then it is likely to fail, e.g. on invoice_open. Meaning that a transaction that could have been processed will become an undead transaction. To avoid that situation we set an arbitrary retry_limit_date set to 2 days, which seems a reasonnable compromise. It gives some time for the transaction to go through, but not exaggeratedly so. opw 1945953 closes odoo/odoo#31791 Signed-off-by: Toufik Benjaa (tbe) <tbe@odoo.com>
This commit is contained in:
@@ -785,10 +785,13 @@ class PaymentTransaction(models.Model):
|
||||
def _cron_post_process_after_done(self):
|
||||
if not self:
|
||||
ten_minutes_ago = datetime.now() - relativedelta.relativedelta(minutes=10)
|
||||
# we don't want to forever try to process a transaction that doesn't go through
|
||||
retry_limit_date = datetime.now() - relativedelta.relativedelta(days=2)
|
||||
# we retrieve all the payment tx that need to be post processed
|
||||
self = self.search([('state', '=', 'done'),
|
||||
('is_processed', '=', False),
|
||||
('date', '<=', ten_minutes_ago),
|
||||
('date', '>=', retry_limit_date),
|
||||
])
|
||||
for tx in self:
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user