diff --git a/bin/addons/base/ir/ir_attachment.py b/bin/addons/base/ir/ir_attachment.py index 74502d374d2..480d6782912 100644 --- a/bin/addons/base/ir/ir_attachment.py +++ b/bin/addons/base/ir/ir_attachment.py @@ -44,10 +44,13 @@ class ir_attachment(osv.osv): if values: if 'res_model' in values and 'res_id' in values: res_ids.setdefault(values['res_model'],[]).append(values['res_id']) - + for model, mids in res_ids.items(): - cr.execute('select id from '+self.pool.get(model)._table+' where id in %s', (tuple(ids),)) + # ignore attachments that are not attached to a resource anymore when checking access rights + # (resource was deleted but attachment was not) + cr.execute('select id from '+self.pool.get(model)._table+' where id in %s', (tuple(mids),)) mids = [x[0] for x in cr.fetchall()] + self.pool.get(model).check_access_rule(cr, uid, mids, mode, context=context) def search(self, cr, uid, args, offset=0, limit=None, order=None,