summaryrefslogtreecommitdiff
path: root/addons/document/document_directory.py
diff options
context:
space:
mode:
authorHarry (OpenERP) <hmo@tinyerp.com>2010-10-15 18:44:59 +0530
committerHarry (OpenERP) <hmo@tinyerp.com>2010-10-15 18:44:59 +0530
commit824042bb1cd0ce992e7ab4789497487b95b12fb8 (patch)
tree1600ed5e35d7de81b4b2795e33a591466a0b3474 /addons/document/document_directory.py
parentc7c8bdf909fe91c1522598969b819542e0469f04 (diff)
parentecbd4323e8e8b34bbdd73f0524478914e76dd6ba (diff)
[MERGE]
bzr revid: hmo@tinyerp.com-20101015131459-k969h71ybafv5kib
Diffstat (limited to 'addons/document/document_directory.py')
-rw-r--r--addons/document/document_directory.py47
1 files changed, 44 insertions, 3 deletions
diff --git a/addons/document/document_directory.py b/addons/document/document_directory.py
index 47cea1e86bf..9b7ba18b16f 100644
--- a/addons/document/document_directory.py
+++ b/addons/document/document_directory.py
@@ -125,6 +125,10 @@ class document_directory(osv.osv):
def get_full_path(self, cr, uid, dir_id, context=None):
""" Return the full path to this directory, in a list, root first
"""
+ if isinstance(dir_id, (tuple, list)):
+ assert len(dir_id) == 1
+ dir_id = dir_id[0]
+
def _parent(dir_id, path):
parent=self.browse(cr, uid, dir_id)
if parent.parent_id and not parent.ressource_parent_type_id:
@@ -174,6 +178,39 @@ class document_directory(osv.osv):
return nodes.get_node_context(cr, uid, context).get_uri(cr, uri)
+ def get_node_class(self, cr, uid, ids, dbro=None, dynamic=False, context=None):
+ """Retrieve the class of nodes for this directory
+
+ This function can be overriden by inherited classes ;)
+ @param dbro The browse object, if caller already has it
+ """
+ if dbro is None:
+ dbro = self.browse(cr, uid, ids, context=context)
+
+ if dynamic:
+ assert dbro.type == 'directory'
+ return nodes.node_res_obj
+ elif dbro.type == 'directory':
+ return nodes.node_dir
+ elif dbro.type == 'ressource':
+ return nodes.node_res_dir
+ else:
+ raise ValueError("dir node for %s type", dbro.type)
+
+ def _prepare_context(self, cr, uid, nctx, context):
+ """ Fill nctx with properties for this database
+ @param nctx instance of nodes.node_context, to be filled
+ @param context ORM context (dict) for us
+
+ Note that this function is called *without* a list of ids,
+ it should behave the same for the whole database (based on the
+ ORM instance of document.directory).
+
+ Some databases may override this and attach properties to the
+ node_context. See WebDAV, CalDAV.
+ """
+ return
+
def get_dir_permissions(self, cr, uid, ids ):
"""Check what permission user 'uid' has on directory 'id'
"""
@@ -215,6 +252,7 @@ class document_directory(osv.osv):
name=directory.name
if not parent_id:
parent_id=directory.parent_id and directory.parent_id.id or False
+ # TODO fix algo
if not ressource_parent_type_id:
ressource_parent_type_id=directory.ressource_parent_type_id and directory.ressource_parent_type_id.id or False
if not ressource_id:
@@ -235,8 +273,11 @@ class document_directory(osv.osv):
def create(self, cr, uid, vals, context=None):
if not self._check_duplication(cr, uid, vals):
raise osv.except_osv(_('ValidateError'), _('Directory name must be unique!'))
- if vals.get('name',False) and (vals.get('name').find('/')+1 or vals.get('name').find('@')+1 or vals.get('name').find('$')+1 or vals.get('name').find('#')+1) :
- raise osv.except_osv(_('ValidateError'), _('Directory name contains special characters!'))
+ newname = vals.get('name',False)
+ if newname:
+ for illeg in ('/', '@', '$', '#'):
+ if illeg in newname:
+ raise osv.except_osv(_('ValidateError'), _('Directory name contains special characters!'))
return super(document_directory,self).create(cr, uid, vals, context)
# TODO def unlink(...
@@ -255,7 +296,7 @@ class document_directory_dctx(osv.osv):
_name = 'document.directory.dctx'
_description = 'Directory Dynamic Context'
_columns = {
- 'dir_id': fields.many2one('document.directory', 'Directory', required=True),
+ 'dir_id': fields.many2one('document.directory', 'Directory', required=True, ondelete="cascade"),
'field': fields.char('Field', size=20, required=True, select=1, help="The name of the field. Note that the prefix \"dctx_\" will be prepended to what is typed here."),
'expr': fields.char('Expression', size=64, required=True, help="A python expression used to evaluate the field.\n" + \
"You can use 'dir_id' for current dir, 'res_id', 'res_model' as a reference to the current record, in dynamic folders"),