[FIX] snailmail: dont resend without credits

We are spammed by some accounts that don't have credits anymore.

With this commit, when we try to send letters from the cron, whenever we
meet the CREDIT_ERROR error_code, we stop trying to send the letter.

task-2930455

closes odoo/odoo#103530

X-original-commit: f1fed40e2f853ecd9e5c24e0882c67f9505155c2
Signed-off-by: Florian Daloze (fda) <fda@odoo.com>
This commit is contained in:
Arthur (goa)
2022-10-20 17:16:58 +02:00
parent c79016fbc6
commit a9702cee39
@@ -417,6 +417,8 @@ class SnailmailLetter(models.Model):
])
for letter in letters_send:
letter._snailmail_print()
if letter.error_code == 'CREDIT_ERROR':
break # avoid spam
# Commit after every letter sent to avoid to send it again in case of a rollback
if autocommit:
self.env.cr.commit()