Browse Source

Merge PR #51 into 12.0

Signed-off-by Yajo
pull/58/head
OCA-git-bot 3 years ago
parent
commit
0852f2855b
  1. 34
      privacy_consent/models/mail_mail.py

34
privacy_consent/models/mail_mail.py

@ -11,26 +11,24 @@ class MailMail(models.Model):
failure_type=None):
"""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,
self._prefetch,
)
# Set as sent if needed
res_ids = []
for mail in self:
if (
consent.state == "draft"
and consent.partner_id.id in {par.id for par in success_pids}
mail.mail_message_id.model == "privacy.consent"
and mail.state == "sent"
and success_pids
and not failure_reason
and not failure_type
):
consent.write({
"state": "sent",
})
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