[FIX] mail_tracking: do not warn not found if already opened

The state will be 'opened' after first time email is opened. Each
successive open triggered warning, because state was already 'opened'
and thus did not match domain state in (sent, delivered).

Forward-port #d9ad3464
This commit is contained in:
Uku Lagle 2020-03-30 19:41:27 +03:00 committed by Jasmin Solanki
parent a85b2cb53b
commit 2718b80146

View File

@ -81,18 +81,14 @@ class MailTrackingController(MailController):
with db_env(db) as env:
try:
tracking_email = env["mail.tracking.email"].search(
[
("id", "=", tracking_email_id),
("state", "in", ["sent", "delivered"]),
("token", "=", token),
]
[("id", "=", tracking_email_id), ("token", "=", token)]
)
if tracking_email:
tracking_email.event_create("open", metadata)
else:
if not tracking_email:
_logger.warning(
"MailTracking email '%s' not found", tracking_email_id
)
elif tracking_email.state in ("sent", "delivered"):
tracking_email.event_create("open", metadata)
except Exception:
pass