summaryrefslogtreecommitdiff
path: root/addons/document
diff options
context:
space:
mode:
authorP. Christeas <p_christ@hol.gr>2010-08-27 10:39:55 +0300
committerP. Christeas <p_christ@hol.gr>2010-08-27 10:39:55 +0300
commit8a107a7e52e2b6fe423dd491f1c4c5fac44b99a9 (patch)
treec1f7c338ddc7d06150429ce6b4ef94e47fa6860a /addons/document
parent6b70730393870cea1ce497fbe123495794532dfd (diff)
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
Diffstat (limited to 'addons/document')
-rw-r--r--addons/document/document.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/addons/document/document.py b/addons/document/document.py
index 46cf6d189c1..084d4bcd88d 100644
--- a/addons/document/document.py
+++ b/addons/document/document.py
@@ -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)