From 0a0fe59f6df0e358f7424b21806667eae3fb7904 Mon Sep 17 00:00:00 2001 From: Justine Doutreloux Date: Fri, 17 May 2024 14:24:14 +0200 Subject: [PATCH] [FIX] connector_search_engine: if the user doesn't have the rights on se_binding the compute, write and unlink will fail --- connector_search_engine/models/se_indexable_record.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/connector_search_engine/models/se_indexable_record.py b/connector_search_engine/models/se_indexable_record.py index 206f87de..fa55f7ec 100644 --- a/connector_search_engine/models/se_indexable_record.py +++ b/connector_search_engine/models/se_indexable_record.py @@ -60,6 +60,7 @@ class SeIndexableRecord(models.AbstractModel): string="Seacrh Engine Bindings", comodel_name="se.binding", compute="_compute_binding_ids", + compute_sudo=True, ) count_se_binding_total = fields.Integer(compute="_compute_count_binding") count_se_binding_done = fields.Integer(compute="_compute_count_binding") @@ -170,8 +171,8 @@ def _se_mark_to_update(self, indexes: SeIndex | None = None) -> None: bindings.write({"state": "to_recompute"}) def unlink(self): - bindings = self._get_bindings() - bindings.write( + bindings = self.sudo()._get_bindings() + bindings.sudo().write( { "state": "to_delete", "res_id": False, @@ -186,7 +187,7 @@ def write(self, vals): # if the record is archived then unarchived while the binding # are not already deleted we reset the state to_recompute new_state = "to_recompute" if vals["active"] else "to_delete" - bindings.write( + bindings.sudo().write( { "state": new_state, }