Document: fix unlink, where storage_id is not at first parent.

The convention is that storage_id may exist at any level up the
parent folders, so we have to recursively search for it.

bzr revid: p_christ@hol.gr-20100827073955-eyja6mhhy7rt5peh
This commit is contained in:
P. Christeas
2010-08-27 10:39:55 +03:00
parent 6b70730393
commit 8a107a7e52
+10 -2
View File
@@ -240,7 +240,7 @@ class document_file(osv.osv):
return bro.address_id.partner_id.id
return False
def unlink(self, cr, uid, ids, context={}):
def unlink(self, cr, uid, ids, context=None):
stor = self.pool.get('document.storage')
unres = []
# We have to do the unlink in 2 stages: prepare a list of actual
@@ -250,7 +250,15 @@ class document_file(osv.osv):
for f in self.browse(cr, uid, ids, context):
# TODO: update the node cache
r = stor.prepare_unlink(cr, uid, f.parent_id.storage_id, f)
par = f.parent_id
storage_id = None
while par:
if par.storage_id:
storage_id = par.storage_id
break
par = par.parent_id
assert storage_id, "Strange, found file #%s w/o storage!" % f.id
r = stor.prepare_unlink(cr, uid, storage_id, f)
if r:
unres.append(r)
res = super(document_file, self).unlink(cr, uid, ids, context)