[FIX] document: duplicate directory detection should work even when a record rule prevent user from seeing duplicates
bzr revid: xal@openerp.com-20131216123954-px10qz9g3qxng6c6
This commit is contained in:
parent
94b4618c13
commit
6fab66d6f7
|
@ -34,6 +34,7 @@ import openerp
|
|||
from openerp import netsvc
|
||||
from openerp import pooler
|
||||
from openerp import tools
|
||||
from openerp import SUPERUSER_ID
|
||||
from openerp.osv import fields, osv
|
||||
from openerp.osv.orm import except_orm
|
||||
from openerp.tools.misc import ustr
|
||||
|
@ -323,7 +324,7 @@ class document_directory(osv.osv):
|
|||
ressource_parent_type_id=vals.get('ressource_parent_type_id',False)
|
||||
ressource_id=vals.get('ressource_id',0)
|
||||
if op=='write':
|
||||
for directory in self.browse(cr, uid, ids):
|
||||
for directory in self.browse(cr, SUPERUSER_ID, ids):
|
||||
if not name:
|
||||
name=directory.name
|
||||
if not parent_id:
|
||||
|
@ -337,7 +338,7 @@ class document_directory(osv.osv):
|
|||
if len(res):
|
||||
return False
|
||||
if op=='create':
|
||||
res=self.search(cr,uid,[('name','=',name),('parent_id','=',parent_id),('ressource_parent_type_id','=',ressource_parent_type_id),('ressource_id','=',ressource_id)])
|
||||
res = self.search(cr, SUPERUSER_ID, [('name','=',name),('parent_id','=',parent_id),('ressource_parent_type_id','=',ressource_parent_type_id),('ressource_id','=',ressource_id)])
|
||||
if len(res):
|
||||
return False
|
||||
return True
|
||||
|
|
|
@ -58,6 +58,23 @@
|
|||
!python {model: ir.attachment}: |
|
||||
ids = self.search(cr, uid, [('res_model', '=', 'res.country'), ('res_id', '=', ref("base.za"))])
|
||||
assert ids == [ ref("attach_3rd")], ids
|
||||
-
|
||||
I test that I can't create duplicate directories (even when duplicates are hidden by a record rule)
|
||||
-
|
||||
!python {model: document.directory}: |
|
||||
duplicate_detected = False
|
||||
from openerp.osv.osv import except_osv
|
||||
try:
|
||||
demo_uid = ref('base.user_demo')
|
||||
dir_vals = {
|
||||
'name': 'Testing (will be deleted!)',
|
||||
'parent_id': ref('document.dir_root')
|
||||
}
|
||||
new_dir_id = self.create(cr, demo_uid, dir_vals, context=None)
|
||||
self.unlink(cr, uid, [new_dir_id], context=None)
|
||||
except except_osv, e:
|
||||
duplicate_detected = e.value == u'Directory name must be unique!'
|
||||
assert duplicate_detected is True, 'Failed to detect duplicate directory'
|
||||
-
|
||||
I delete the attachments
|
||||
-
|
||||
|
|
Loading…
Reference in New Issue