Browse Source

Merge PR #53 into 13.0

Signed-off-by pedrobaeza
pull/54/head
OCA-git-bot 4 years ago
parent
commit
0c3326e11c
  1. 32
      privacy_consent/models/mail_mail.py

32
privacy_consent/models/mail_mail.py

@ -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,

Loading…
Cancel
Save