summaryrefslogtreecommitdiff
path: root/addons/document/document.py
diff options
context:
space:
mode:
authorMartin Trigaux <mat@openerp.com>2013-07-22 13:51:06 +0200
committerMartin Trigaux <mat@openerp.com>2013-07-22 13:51:06 +0200
commit5480f2958e34d5cb36de2f9506cee6516c4f4967 (patch)
tree9b30e905d0777efca47c72444bdc8c2a402ebc8c /addons/document/document.py
parentca4cc04c68c848a2de51bc2a5e7ccbfe1760d62a (diff)
[FIX] same without record rules, python side
bzr revid: mat@openerp.com-20130722115106-b1uldamgbpisf84g
Diffstat (limited to 'addons/document/document.py')
-rw-r--r--addons/document/document.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/addons/document/document.py b/addons/document/document.py
index 1671b6bc1ba..a841f071b91 100644
--- a/addons/document/document.py
+++ b/addons/document/document.py
@@ -69,11 +69,17 @@ class document_file(osv.osv):
]
def check(self, cr, uid, ids, mode, context=None, values=None):
- """Check access wrt. res_model, relax the rule of ir.attachment parent
- With 'document' installed, everybody will have access to attachments of
- any resources they can *read*.
- """
- return super(document_file, self).check(cr, uid, ids, mode='read', context=context, values=values)
+ super(document_file, self).check(cr, uid, ids, mode, context=context, values=values)
+ if ids:
+ # use SQL to avoid recursive loop on read
+ cr.execute('SELECT id, parent_id from ir_attachment WHERE id in %s', (tuple(ids),))
+
+ parent_ids = []
+ for attach_id, attach_parent in cr.fetchall():
+ if attach_parent:
+ parent_ids.append(attach_parent)
+
+ self.pool.get('document.directory').check_access_rule(cr, uid, parent_ids, mode, context=context)
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
# Grab ids, bypassing 'count'