[FIX] solved: unlink issue due to bad migration

This commit is contained in:
mreficent 2020-07-08 20:37:18 +02:00 committed by augusto-weiss
parent 9a333a98a3
commit 268ccdae9a

View File

@ -1,7 +1,7 @@
# Copyright 2018 David Juaneda - <djuaneda@sdi.es> # Copyright 2018 David Juaneda - <djuaneda@sdi.es>
# Copyright 2018 Eficent Business and IT Consulting Services, S.L. # Copyright 2018 Eficent Business and IT Consulting Services, S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import SUPERUSER_ID, api, fields, models from odoo import api, fields, models
class MailActivity(models.Model): class MailActivity(models.Model):
@ -73,7 +73,7 @@ class MailActivity(models.Model):
access_rights_uid=None, access_rights_uid=None,
): ):
# Rules do not apply to administrator # Rules do not apply to administrator
if self._uid == SUPERUSER_ID: if self.env.is_superuser():
return super(MailActivity, self)._search( return super(MailActivity, self)._search(
args, args,
offset=offset, offset=offset,
@ -103,17 +103,19 @@ class MailActivity(models.Model):
model_ids = {} model_ids = {}
self._cr.execute( self.flush(["res_id", "res_model_id", "res_model"])
""" for sub_ids in self._cr.split_for_in_conditions(ids):
SELECT DISTINCT a.id, im.id, im.model, a.res_id self._cr.execute(
FROM "%s" a """
LEFT JOIN ir_model im ON im.id = a.res_model_id SELECT DISTINCT a.id, im.id, im.model, a.res_id
WHERE a.id = ANY (%%(ids)s)""" FROM "%s" a
% self._table, LEFT JOIN ir_model im ON im.id = a.res_model_id
dict(ids=ids), WHERE a.id = ANY (%%(ids)s)"""
) % self._table,
for a_id, _ir_model_id, model, model_id in self._cr.fetchall(): dict(ids=list(sub_ids)),
model_ids.setdefault(model, {}).setdefault(model_id, set()).add(a_id) )
for a_id, _ir_model_id, model, model_id in self._cr.fetchall():
model_ids.setdefault(model, {}).setdefault(model_id, set()).add(a_id)
allowed_ids = self._find_allowed_doc_ids(model_ids) allowed_ids = self._find_allowed_doc_ids(model_ids)