summaryrefslogtreecommitdiff
path: root/addons/document/nodes.py
diff options
context:
space:
mode:
authorHarry (Open ERP) <hmo@tinyerp.com>2010-03-16 18:43:28 +0530
committerHarry (Open ERP) <hmo@tinyerp.com>2010-03-16 18:43:28 +0530
commit0db347d65f9c67f4b114a96874ea120cf7eacdee (patch)
tree14b476a2f5cfca2255c1a289b40a64ce35531dac /addons/document/nodes.py
parent4b08bc496fe4945b25580d004b7f8745d00f7b15 (diff)
parentb509b2d0867f0283e7876c6ee636f7e18f48f11e (diff)
[MERGE] merged from lp:~openerp-commiter/openobject-addons/crm-improvement
bzr revid: hmo@tinyerp.com-20100316131328-lgttnpy712rqr7ga
Diffstat (limited to 'addons/document/nodes.py')
-rw-r--r--addons/document/nodes.py33
1 files changed, 32 insertions, 1 deletions
diff --git a/addons/document/nodes.py b/addons/document/nodes.py
index c6e2f1b10d1..543610a0d22 100644
--- a/addons/document/nodes.py
+++ b/addons/document/nodes.py
@@ -599,7 +599,33 @@ class node_file(node_class):
self.storage_id = fil.parent_id.storage_id.id
else:
self.storage_id = None
-
+
+ def fix_ppath(self, cr, fbro):
+ """Sometimes we may init this w/o path, parent.
+ This function fills the missing path from the file browse object
+
+ Note: this may be an expensive operation, do on demand. However,
+ once caching is in, we might want to do that at init time and keep
+ this object anyway
+ """
+ if self.path or self.parent:
+ return
+ assert fbro
+ uid = self.context.uid
+
+ dirpath = []
+ if fbro.parent_id:
+ dirobj = self.context._dirobj.pool.get('document.directory')
+ dirpath = dirobj.get_full_path(cr, uid, fbro.parent_id.id, context=self.context.context)
+ if fbro.datas_fname:
+ dirpath.append(fbro.datas_fname)
+ else:
+ dirpath.append(fbro.name)
+
+ if len(dirpath)>1:
+ self.path = dirpath
+ else:
+ self.path = dirpath[0]
def get_data(self, cr, fil_obj = None):
""" Retrieve the data for some file.
@@ -631,6 +657,11 @@ class node_file(node_class):
the browse object. """
# this is where storage kicks in..
stor = self.storage_id
+ if not stor:
+ data_obj = self.context._dirobj.pool.get('ir.model.data')
+ data_id = data_obj._get_id(cr, self.context.uid, 'document', 'storage_db')
+ if data_id:
+ stor = data_obj.browse(cr, self.context.uid, data_id, context=self.context.context).res_id
assert stor
stobj = self.context._dirobj.pool.get('document.storage')
return stobj.set_data(cr,self.context.uid,stor, self, data, self.context.context, fil_obj)