diff options
| author | pso (tiny) <pso@tinyerp.com> | 2009-01-05 11:34:12 +0530 |
|---|---|---|
| committer | pso (tiny) <pso@tinyerp.com> | 2009-01-05 11:34:12 +0530 |
| commit | cff804f5f868d6ade63995c54f32c523fa22d77c (patch) | |
| tree | f5821ee2f0567c11280a44124346b2ba8db1daf2 /addons/document/document.py | |
| parent | 3340f800f0f570fa6948fc4da18eb921c6c6326b (diff) | |
| parent | 21f104a506545f869453c7aa9416ce40c49a1c00 (diff) | |
merge
bzr revid: pso@tinyerp.com-20090102045406-ko0sbzkugrhsq0h3
bzr revid: pso@tinyerp.com-20090105060412-448pd2c8hlm5r4e3
Diffstat (limited to 'addons/document/document.py')
| -rw-r--r-- | addons/document/document.py | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/addons/document/document.py b/addons/document/document.py index 75cbdeb2797..0b6c3dbbc2c 100644 --- a/addons/document/document.py +++ b/addons/document/document.py @@ -2,7 +2,7 @@ ############################################################################## # # OpenERP, Open Source Management Solution -# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved +# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved # $Id$ # # This program is free software: you can redistribute it and/or modify @@ -87,27 +87,28 @@ class node_class(object): if self.object2: where.append( ('res_model','=',self.object2._name) ) where.append( ('res_id','=',self.object2.id) ) - for content in self.object.content_ids: - if self.object2 or not content.include_name: - if content.include_name: - test_nodename = self.object2.name + (content.suffix or '') + (content.extension or '') - else: - test_nodename = (content.suffix or '') + (content.extension or '') - if test_nodename.find('/'): - test_nodename=test_nodename.replace('/', '_') - path = self.path+'/'+test_nodename - if not nodename: - n = node_class(self.cr, self.uid,path, self.object2, False, content=content, type='content', root=False) - res2.append( n) - else: - if nodename == test_nodename: - n = node_class(self.cr, self.uid, path, self.object2, False, content=content, type='content', root=False) - res2.append(n) else: where.append( ('parent_id','=',self.object.id) ) where.append( ('res_id','=',False) ) if nodename: - where.append( (fobj._rec_name,'like',nodename) ) + where.append( (fobj._rec_name,'like',nodename) ) + for content in self.object.content_ids: + if self.object2 or not content.include_name: + if content.include_name: + test_nodename = self.object2.name + (content.suffix or '') + (content.extension or '') + else: + test_nodename = (content.suffix or '') + (content.extension or '') + if test_nodename.find('/'): + test_nodename=test_nodename.replace('/', '_') + path = self.path+'/'+test_nodename + if not nodename: + n = node_class(self.cr, self.uid,path, self.object2, False, content=content, type='content', root=False) + res2.append( n) + else: + if nodename == test_nodename: + n = node_class(self.cr, self.uid, path, self.object2, False, content=content, type='content', root=False) + res2.append(n) + ids = fobj.search(self.cr, self.uid, where+[ ('parent_id','=',self.object and self.object.id or False) ], context=self.context) if self.object and self.root and (self.object.type=='ressource'): ids += fobj.search(self.cr, self.uid, where+[ ('parent_id','=',False) ], context=self.context) @@ -583,6 +584,9 @@ class document_file(osv.osv): default.update({'name': name+ " (copy)"}) return super(document_file,self).copy(cr,uid,id,default,context) def write(self, cr, uid, ids, vals, context=None): + res=self.search(cr,uid,[('id','in',ids)]) + if not len(res): + return False if not self._check_duplication(cr,uid,vals,ids,'write'): raise except_orm('ValidateError', 'File name must be unique!') result = super(document_file,self).write(cr,uid,ids,vals,context=context) |
