summaryrefslogtreecommitdiff
path: root/addons/document
diff options
context:
space:
mode:
authorP. Christeas <p_christ@hol.gr>2010-12-09 12:01:21 +0200
committerP. Christeas <p_christ@hol.gr>2010-12-09 12:01:21 +0200
commit0cb5ccb45d72356e72b0fb025b06360d62a3fbf6 (patch)
tree3b53844b8e6e8fb80f3df4748eea55ae955fc816 /addons/document
parenta726297a51ac679dd708541bcb8d2a57ac0db650 (diff)
document: fix behavior of resource-hooked folders [Bug 682761]
Original report: > From: Dr. Ferdinand Gasauer > Date: 29-11-2010 > Subject: webdav - create folder duplicates existing attachments > to reproduce > add attachment to partner using webdav (konqueror 4.5.3) > create new folder in webdav directory > the attachment will be displayed ALSO in the newly created folder Well, this /did/ work as the code intended, but not as a user would expect. As of commit e549808c0e90, the resource directories would list _all_ attachments referencing some record, by default. This meant that a newly created folder with files [and subfolders with files..] would have all the files listed at the root folder, too eg. /Dirs/Products/Product-A/ + [ /dir2/a.txt, /dir2/b.txt ] would list a.txt, b.txt under ../Product-A/ , too. Now, the algorithm is improved to handle such a case and turn off the "find all" flag[1] so that child files will be contained in their folders[2]. [1] I'm now glad I had left that option there. [2] still, files may all appear at the root folder, too, if this has the "find-all" flag set. bzr revid: p_christ@hol.gr-20101209100121-6kaq1zcqfewwl25b
Diffstat (limited to 'addons/document')
-rw-r--r--addons/document/document_view.xml4
-rw-r--r--addons/document/nodes.py35
2 files changed, 26 insertions, 13 deletions
diff --git a/addons/document/document_view.xml b/addons/document/document_view.xml
index 536683f6a59..df5e78894fd 100644
--- a/addons/document/document_view.xml
+++ b/addons/document/document_view.xml
@@ -82,7 +82,6 @@
<group colspan="4" col="4" attrs="{'invisible': [('type','!=','ressource')]}">
<field name="ressource_type_id" on_change="onchange_content_id(ressource_type_id)"
attrs="{'required': [('type','=','ressource')] }"/>
- <field name="resource_find_all" groups="base.group_extended" />
<newline/>
<field name="resource_field" domain="[('model_id','=',ressource_type_id), ('ttype', 'in', ('char', 'selection', 'date', 'datetime'))]"/>
<field name="ressource_tree"/>
@@ -93,6 +92,9 @@
<field name="ressource_parent_type_id"/>
<field name="ressource_id" select="2" readonly="1"/>
</group>
+ <group colspan="4" col="2" attrs="{'invisible': [('type','!=','ressource'),('resource_parent_type_id','=',False)]}">
+ <field name="resource_find_all" groups="base.group_extended" />
+ </group>
</page>
<page string="Generated Files" groups="base.group_extended">
diff --git a/addons/document/nodes.py b/addons/document/nodes.py
index 1f90b7922be..1b7aebcd389 100644
--- a/addons/document/nodes.py
+++ b/addons/document/nodes.py
@@ -908,7 +908,10 @@ class node_res_obj(node_class):
self.domain = parent.domain
self.displayname = path
self.dctx_dict = parent.dctx_dict
- self.res_find_all = parent.res_find_all
+ if isinstance(parent, node_res_dir):
+ self.res_find_all = parent.res_find_all
+ else:
+ self.res_find_all = False
if res_bo:
self.res_id = res_bo.id
dc2 = self.context.context.copy()
@@ -1045,27 +1048,32 @@ class node_res_obj(node_class):
continue
# TODO Revise
klass = directory.get_node_class(directory, dynamic=True, context=ctx)
- res.append(klass(res_name, dir_id=self.dir_id, parent=self, context=self.context, res_model=self.res_model, res_bo=bo))
+ rnode = klass(res_name, dir_id=self.dir_id, parent=self, context=self.context,
+ res_model=self.res_model, res_bo=bo)
+ rnode.res_find_all = self.res_find_all
+ res.append(rnode)
where2 = where + [('parent_id','=',self.dir_id) ]
ids = dirobj.search(cr, uid, where2, context=ctx)
+ bo = obj.browse(cr, uid, self.res_id, context=ctx)
+
for dirr in dirobj.browse(cr, uid, ids, context=ctx):
if name and (name != dirr.name):
continue
if dirr.type == 'directory':
klass = dirr.get_node_class(dirr, dynamic=True, context=ctx)
- res.append(klass(dirr.name, dirr.id, self, self.context, self.res_model, res_bo = None, res_id = self.res_id))
+ res.append(klass(dirr.name, dirr.id, self, self.context, self.res_model, res_bo = bo, res_id = self.res_id))
elif dirr.type == 'ressource':
# child resources can be controlled by properly set dctx
klass = dirr.get_node_class(dirr, context=ctx)
- res.append(klass(dirr.name,self,self.context, dirr, {'active_id': self.res_id}))
+ res.append(klass(dirr.name,self,self.context, dirr, {'active_id': self.res_id})) # bo?
fil_obj = dirobj.pool.get('ir.attachment')
if self.res_find_all:
where2 = where
- where3 = where2 + [('res_model', '=', self.res_model), ('res_id','=',self.res_id)]
- # print "where clause for dir_obj", where2
+ where3 = where2 + [('res_model', '=', self.res_model), ('res_id','=',self.res_id)]
+ # print "where clause for dir_obj", where3
ids = fil_obj.search(cr, uid, where3, context=ctx)
if ids:
for fil in fil_obj.browse(cr, uid, ids, context=ctx):
@@ -1076,17 +1084,19 @@ class node_res_obj(node_class):
# Get Child Ressource Directories
if directory.ressource_type_id and directory.ressource_type_id.id:
where4 = where + [('ressource_parent_type_id','=',directory.ressource_type_id.id)]
- where5 = where4 + [('ressource_id','=',0)]
+ where5 = where4 + ['|', ('ressource_id','=',0), ('ressource_id','=',self.res_id)]
dirids = dirobj.search(cr,uid, where5)
- where5 = where4 + [('ressource_id','=',self.res_id)]
- dirids = dirids + dirobj.search(cr,uid, where5)
for dirr in dirobj.browse(cr, uid, dirids, context=ctx):
if dirr.type == 'directory' and not dirr.parent_id:
klass = dirr.get_node_class(dirr, dynamic=True, context=ctx)
- res.append(klass(dirr.name, dirr.id, self, self.context, self.res_model, res_bo = None, res_id = self.res_id))
+ rnode = klass(dirr.name, dirr.id, self, self.context, self.res_model, res_bo = bo, res_id = self.res_id)
+ rnode.res_find_all = dirr.resource_find_all
+ res.append(rnode)
if dirr.type == 'ressource':
klass = dirr.get_node_class(dirr, context=ctx)
- res.append(klass(dirr.name, self, self.context, dirr, {'active_id': self.res_id}))
+ rnode = klass(dirr.name, self, self.context, dirr, {'active_id': self.res_id})
+ rnode.res_find_all = dirr.resource_find_all
+ res.append(rnode)
return res
def create_child_collection(self, cr, objname):
@@ -1111,7 +1121,8 @@ class node_res_obj(node_class):
'name': objname,
'ressource_parent_type_id': obj and obj.ressource_type_id.id or False,
'ressource_id': object2 and object2.id or False,
- 'parent_id' : False
+ 'parent_id' : False,
+ 'resource_find_all': False,
}
if (obj and (obj.type in ('directory'))) or not object2:
val['parent_id'] = obj and obj.id or False