From cbac74899019a2aa6283b8054891d3058e5d169c Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Wed, 27 Oct 2010 13:23:23 +0300 Subject: Doc: more help on Model-Parented folders. Their usage is a little cryptic, so help the user understand how they work. bzr revid: p_christ@hol.gr-20101027102323-q0i1a5u6ausoj4uv --- addons/document/document_directory.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'addons/document/document_directory.py') diff --git a/addons/document/document_directory.py b/addons/document/document_directory.py index 9b7ba18b16f..c4df8a7cf18 100644 --- a/addons/document/document_directory.py +++ b/addons/document/document_directory.py @@ -58,8 +58,10 @@ class document_directory(osv.osv): " be located. If false, only ones that have this as parent." ), 'ressource_parent_type_id': fields.many2one('ir.model', 'Parent Model', help="If you put an object here, this directory template will appear bellow all of these objects. " \ + "Such directories are \"attached\" to the specific model or record, just like attachments. " \ "Don't put a parent directory if you select a parent model."), - 'ressource_id': fields.integer('Resource ID'), + 'ressource_id': fields.integer('Resource ID', + help="Along with Parent Model, this ID attaches this folder to a specific record of Parent Model."), 'ressource_tree': fields.boolean('Tree Structure', help="Check this if you want to use the same tree structure as the object selected in the system."), 'dctx_ids': fields.one2many('document.directory.dctx', 'dir_id', 'Context fields'), -- cgit v1.2.3 From 7539d4051c3236bb33cae36917ab4d39716db120 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Wed, 27 Oct 2010 13:23:23 +0300 Subject: document: fix recursive (tree) resource directories The 'node_res_obj' has been the right class to use for the intermediate nodes, ever since. The assertion that it should only apply to static dirs was wrong. bzr revid: p_christ@hol.gr-20101027102323-qewjjzzudj0zz643 --- addons/document/document_directory.py | 1 - 1 file changed, 1 deletion(-) (limited to 'addons/document/document_directory.py') diff --git a/addons/document/document_directory.py b/addons/document/document_directory.py index c4df8a7cf18..907a3aaccad 100644 --- a/addons/document/document_directory.py +++ b/addons/document/document_directory.py @@ -190,7 +190,6 @@ class document_directory(osv.osv): 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 -- cgit v1.2.3 From 0f5a276365e9fd06306466b82938bfd3e5a5998f Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Wed, 27 Oct 2010 13:23:24 +0300 Subject: document: use 'change_default' on key fields, cleanup defaults As from a later commit, we will need to adjust default values to different directories (such as permissions etc.). bzr revid: p_christ@hol.gr-20101027102324-duffxdogcczqo67r --- addons/document/document_directory.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'addons/document/document_directory.py') diff --git a/addons/document/document_directory.py b/addons/document/document_directory.py index 907a3aaccad..e75d1861201 100644 --- a/addons/document/document_directory.py +++ b/addons/document/document_directory.py @@ -38,9 +38,9 @@ class document_directory(osv.osv): 'create_uid': fields.many2one('res.users', 'Creator', readonly=True), 'domain': fields.char('Domain', size=128, help="Use a domain if you want to apply an automatic filter on visible resources."), 'user_id': fields.many2one('res.users', 'Owner'), - 'storage_id': fields.many2one('document.storage', 'Storage'), + 'storage_id': fields.many2one('document.storage', 'Storage', change_default=True), 'group_ids': fields.many2many('res.groups', 'document_directory_group_rel', 'item_id', 'group_id', 'Groups'), - 'parent_id': fields.many2one('document.directory', 'Parent Directory', select=1), + 'parent_id': fields.many2one('document.directory', 'Parent Directory', select=1, change_default=True), 'child_ids': fields.one2many('document.directory', 'parent_id', 'Children'), 'file_ids': fields.one2many('ir.attachment', 'parent_id', 'Files'), 'content_ids': fields.one2many('document.directory.content', 'directory_id', 'Virtual Files'), @@ -48,15 +48,15 @@ class document_directory(osv.osv): ('directory','Static Directory'), ('ressource','Folders per resource'), ], - 'Type', required=True, select=1, + 'Type', required=True, select=1, change_default=True, help="Each directory can either have the type Static or be linked to another resource. A static directory, as with Operating Systems, is the classic directory that can contain a set of files. The directories linked to systems resources automatically possess sub-directories for each of resource types defined in the parent directory."), - 'ressource_type_id': fields.many2one('ir.model', 'Resource model', + 'ressource_type_id': fields.many2one('ir.model', 'Resource model', change_default=True, help="Select an object here and there will be one folder per record of that resource."), 'resource_field': fields.many2one('ir.model.fields', 'Name field', help='Field to be used as name on resource directories. If empty, the "name" will be used.'), 'resource_find_all': fields.boolean('Find all resources', required=True, help="If true, all attachments that match this resource will " \ " be located. If false, only ones that have this as parent." ), - 'ressource_parent_type_id': fields.many2one('ir.model', 'Parent Model', + 'ressource_parent_type_id': fields.many2one('ir.model', 'Parent Model', change_default=True, help="If you put an object here, this directory template will appear bellow all of these objects. " \ "Such directories are \"attached\" to the specific model or record, just like attachments. " \ "Don't put a parent directory if you select a parent model."), @@ -65,7 +65,7 @@ class document_directory(osv.osv): 'ressource_tree': fields.boolean('Tree Structure', help="Check this if you want to use the same tree structure as the object selected in the system."), 'dctx_ids': fields.one2many('document.directory.dctx', 'dir_id', 'Context fields'), - 'company_id': fields.many2one('res.company', 'Company'), + 'company_id': fields.many2one('res.company', 'Company', change_default=True), } @@ -100,10 +100,10 @@ class document_directory(osv.osv): _defaults = { 'company_id': lambda s,cr,uid,c: s.pool.get('res.company')._company_default_get(cr, uid, 'document.directory', context=c), 'user_id': lambda self,cr,uid,ctx: uid, - 'domain': lambda self,cr,uid,ctx: '[]', - 'type': lambda *args: 'directory', - 'ressource_id': lambda *a: 0, - 'storage_id': _get_def_storage, + 'domain': '[]', + 'type': 'directory', + 'ressource_id': 0, + 'storage_id': _get_def_storage, # Still, it is bad practice to set it everywhere. 'resource_find_all': True, } _sql_constraints = [ -- cgit v1.2.3 From 4dae4d0dbfc0d9740e36475b248dab181c8f1aae Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Wed, 27 Oct 2010 13:24:28 +0300 Subject: document: base the dir permissions on ir.rule, not on sql call. bzr revid: p_christ@hol.gr-20101027102428-6n2huvvv2o1tiyh6 --- addons/document/document_directory.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'addons/document/document_directory.py') diff --git a/addons/document/document_directory.py b/addons/document/document_directory.py index e75d1861201..82f53b6120b 100644 --- a/addons/document/document_directory.py +++ b/addons/document/document_directory.py @@ -21,6 +21,7 @@ from osv import osv, fields +from osv.orm import except_orm import os import nodes @@ -212,22 +213,20 @@ class document_directory(osv.osv): """ return - def get_dir_permissions(self, cr, uid, ids ): + def get_dir_permissions(self, cr, uid, ids, context=None ): """Check what permission user 'uid' has on directory 'id' """ assert len(ids) == 1 id = ids[0] - cr.execute( "SELECT count(dg.item_id) AS needs, count(ug.uid) AS has " \ - " FROM document_directory_group_rel dg " \ - " LEFT OUTER JOIN res_groups_users_rel ug " \ - " ON (dg.group_id = ug.gid AND ug.uid = %s) " \ - " WHERE dg.item_id = %s ", (uid, id)) - needs, has = cr.fetchone() - if needs and not has: - return 1 # still allow to descend into. - else: - return 15 + res = 0 + for pperms in [('read', 5), ('write', 2), ('unlink', 8)]: + try: + self.check_access_rule(cr, uid, ids, pperms[0], context=context) + res |= pperms[1] + except except_orm: + pass + return res def _locate_child(self, cr, uid, root_id, uri,nparent, ncontext): """ try to locate the node in uri, -- cgit v1.2.3 From 3389c99ee670a59571def5d1ac670d521ce7d6b5 Mon Sep 17 00:00:00 2001 From: "sbh (Open ERP)" Date: Fri, 12 Nov 2010 17:19:46 +0530 Subject: [Fix] caldav,document,document_ftp,document_webdav: fix buildbot warnings bzr revid: sbh@tinyerp.com-20101112114946-u19wkxzh1vj33sol --- addons/document/document_directory.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'addons/document/document_directory.py') diff --git a/addons/document/document_directory.py b/addons/document/document_directory.py index 82f53b6120b..9412527db22 100644 --- a/addons/document/document_directory.py +++ b/addons/document/document_directory.py @@ -23,7 +23,6 @@ from osv import osv, fields from osv.orm import except_orm -import os import nodes from tools.translate import _ @@ -217,7 +216,6 @@ class document_directory(osv.osv): """Check what permission user 'uid' has on directory 'id' """ assert len(ids) == 1 - id = ids[0] res = 0 for pperms in [('read', 5), ('write', 2), ('unlink', 8)]: -- cgit v1.2.3