From c0db5205886ca1b31c1bf0e5e6210427a1c1afd3 Mon Sep 17 00:00:00 2001 From: benjamin <benjamin@le-filament.com> Date: Wed, 19 Apr 2023 15:08:50 +0200 Subject: [PATCH] [fix] temporary fix OCA error module before merging PR --- models/__init__.py | 1 + models/mail_tracking_email.py | 43 +++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 models/mail_tracking_email.py diff --git a/models/__init__.py b/models/__init__.py index 4d63f95..24777f8 100644 --- a/models/__init__.py +++ b/models/__init__.py @@ -11,3 +11,4 @@ from . import res_partner_ministere from . import scop_liasse_fiscale from . import scop_models_lm from . import scop_partner_staff +from . import mail_tracking_email diff --git a/models/mail_tracking_email.py b/models/mail_tracking_email.py new file mode 100644 index 0000000..eaf37ac --- /dev/null +++ b/models/mail_tracking_email.py @@ -0,0 +1,43 @@ + +from odoo import models + + +class MailTrackingEmail(models.Model): + _inherit = "mail.tracking.email" + + def _find_allowed_tracking_ids(self): + """ + Override parent + TODO: delete afer merge PR https://github.com/OCA/social/pull/1128 + """ + # Admins passby this filter + if not self or self.env.user.has_group("base.group_system"): + return self.ids + # Override ORM to get the values directly + self._cr.execute( + """ + SELECT id, mail_message_id, partner_id + FROM mail_tracking_email WHERE id IN %s + """, + (tuple(self.ids),), + ) + msg_linked = self._cr.fetchall() + if not msg_linked: + return [] + _, msg_ids, partner_ids = zip(*msg_linked) + # Filter messages with their ACL rules avoiding False values fetched in the set + msg_ids = self.env["mail.message"]._search( + [("id", "in", [x for x in msg_ids if x])] + ) + partner_ids = self.env["res.partner"]._search( + [("id", "in", [x for x in partner_ids if x])] + ) + return [ + x[0] + for x in msg_linked + if (x[1] in msg_ids) # We can read the linked message + or ( + not any({x[1], x[2]}) and x[2] in partner_ids + ) # No linked msg/mail but we can read the linked partner + or (not any({x[1], x[2], x[2]})) # No linked record + ] -- GitLab