From a9702cee3997258db8099e5badb2f30bcbceb4d6 Mon Sep 17 00:00:00 2001 From: "Arthur (goa)" Date: Mon, 17 Oct 2022 08:51:38 +0000 Subject: [PATCH] [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) --- addons/snailmail/models/snailmail_letter.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/snailmail/models/snailmail_letter.py b/addons/snailmail/models/snailmail_letter.py index e6bc01809a4..c5162fdde7f 100644 --- a/addons/snailmail/models/snailmail_letter.py +++ b/addons/snailmail/models/snailmail_letter.py @@ -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()