+ dirobj = self.context._dirobj
+ uid = self.context.uid
+ ctx = self.context.context.copy()
+ ctx.update(self.dctx)
+ where = [('parent_id','=',self.dir_id)]
+ if name:
+ where.append(('name','=',name))
+ is_allowed = self.check_perms(1)
+ else:
+ is_allowed = self.check_perms(5)
+
+ if not is_allowed:
+ raise IOError(errno.EPERM, "Permission into directory denied")
+
+ if not domain:
+ domain = []
+
+ where2 = where + domain + [('ressource_parent_type_id','=',False)]
+ ids = dirobj.search(cr, uid, where2, context=ctx)
+ res = []
+ for dirr in dirobj.browse(cr, uid, ids, context=ctx):
+ klass = dirr.get_node_class(dirr, context=ctx)
+ res.append(klass(dirr.name, self, self.context,dirr))
+
+ # Static directories should never return files with res_model/res_id
+ # because static dirs are /never/ related to a record.
+ # In fact, files related to some model and parented by the root dir
+ # (the default), will NOT be accessible in the node system unless
+ # a resource folder for that model exists (with resource_find_all=True).
+ # Having resource attachments in a common folder is bad practice,
+ # because they would be visible to all users, and their names may be
+ # the same, conflicting.
+ where += [('res_model', '=', False)]
+ fil_obj = dirobj.pool.get('ir.attachment')
+ ids = fil_obj.search(cr, uid, where, context=ctx)
+ if ids:
+ for fil in fil_obj.browse(cr, uid, ids, context=ctx):
+ klass = self.context.node_file_class
+ res.append(klass(fil.name, self, self.context, fil))
+ return res