|
|
@ -12,20 +12,24 @@ class MailMail(models.Model): |
|
|
|
): |
|
|
|
"""Write consent status after sending message.""" |
|
|
|
# Know if mail was successfully sent to a privacy consent |
|
|
|
if ( |
|
|
|
self.mail_message_id.model == "privacy.consent" |
|
|
|
and self.state == "sent" |
|
|
|
and success_pids |
|
|
|
and not failure_reason |
|
|
|
and not failure_type |
|
|
|
): |
|
|
|
# Get related consent |
|
|
|
consent = self.env["privacy.consent"].browse(self.mail_message_id.res_id) |
|
|
|
# Set as sent if needed |
|
|
|
if consent.state == "draft" and consent.partner_id.id in { |
|
|
|
par.id for par in success_pids |
|
|
|
}: |
|
|
|
consent.write({"state": "sent"}) |
|
|
|
res_ids = [] |
|
|
|
for mail in self: |
|
|
|
if ( |
|
|
|
mail.mail_message_id.model == "privacy.consent" |
|
|
|
and mail.state == "sent" |
|
|
|
and success_pids |
|
|
|
and not failure_reason |
|
|
|
and not failure_type |
|
|
|
): |
|
|
|
res_ids.append(mail.mail_message_id.res_id) |
|
|
|
consents = self.env["privacy.consent"].search( |
|
|
|
[ |
|
|
|
("id", "in", res_ids), |
|
|
|
("state", "=", "draft"), |
|
|
|
("partner_id", "in", [par.id for par in success_pids]), |
|
|
|
] |
|
|
|
) |
|
|
|
consents.write({"state": "sent"}) |
|
|
|
return super()._postprocess_sent_message( |
|
|
|
success_pids=success_pids, |
|
|
|
failure_reason=failure_reason, |
|
|
|