From 823dc6d50d2a158c0c7428aa09e18a0a0d781a45 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Sun, 27 Jun 2010 23:18:18 +0300 Subject: Document directory: cleanup fields, type, constraints. bzr revid: p_christ@hol.gr-20100627201818-wjlumw10u8g28g27 --- addons/document/document_directory.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'addons/document/document_directory.py') diff --git a/addons/document/document_directory.py b/addons/document/document_directory.py index fee633b7169..d83d1b6b60e 100644 --- a/addons/document/document_directory.py +++ b/addons/document/document_directory.py @@ -39,16 +39,21 @@ class document_directory(osv.osv): 'write_uid': fields.many2one('res.users', 'Last Modification User', readonly=True), 'create_date': fields.datetime('Date Created', readonly=True), 'create_uid': fields.many2one('res.users', 'Creator', readonly=True), - 'file_type': fields.char('Content Type', size=32), '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'), 'group_ids': fields.many2many('res.groups', 'document_directory_group_rel', 'item_id', 'group_id', 'Groups'), - 'parent_id': fields.many2one('document.directory', 'Parent Item'), + 'parent_id': fields.many2one('document.directory', 'Parent Item', select=1), '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'), - 'type': fields.selection([('directory','Static Directory'),('ressource','Other Resources')], 'Type', required=True), + 'type': fields.selection([ + ('directory','Static Directory'), + ('ressource','Folders per resource'), + ('at_record','Single folder under resource')], + 'Type', required=True, select=1, + help="Defines directory's behaviour."), + 'ressource_type_id': fields.many2one('ir.model', 'Directories Mapped to Objects', help="Select an object here and Open ERP will create a mapping for each of these " \ "objects, using the given domain, when browsing through FTP."), @@ -60,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'), } @@ -102,7 +107,8 @@ class document_directory(osv.osv): } _sql_constraints = [ ('dirname_uniq', 'unique (name,parent_id,ressource_id,ressource_parent_type_id)', 'The directory name must be unique !'), - ('no_selfparent', 'check(parent_id <> id)', 'Directory cannot be parent of itself!') + ('no_selfparent', 'check(parent_id <> id)', 'Directory cannot be parent of itself!'), + ('dir_parented', 'check(parent_id IS NOT NULL OR storage_id IS NOT NULL)', 'Directory must have a parent or a storage') ] def name_get(self, cr, uid, ids, context={}): res = [] -- cgit v1.2.3 From 07d395df15c22037d64f0d7dceeec4d1328ce999 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Sun, 27 Jun 2010 23:18:26 +0300 Subject: Document: cleanup the view (and help) of directory. bzr revid: p_christ@hol.gr-20100627201826-1873sa0et2q8vx62 --- addons/document/document_directory.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'addons/document/document_directory.py') diff --git a/addons/document/document_directory.py b/addons/document/document_directory.py index d83d1b6b60e..2872491129d 100644 --- a/addons/document/document_directory.py +++ b/addons/document/document_directory.py @@ -54,9 +54,8 @@ class document_directory(osv.osv): 'Type', required=True, select=1, help="Defines directory's behaviour."), - 'ressource_type_id': fields.many2one('ir.model', 'Directories Mapped to Objects', - help="Select an object here and Open ERP will create a mapping for each of these " \ - "objects, using the given domain, when browsing through FTP."), + 'ressource_type_id': fields.many2one('ir.model', 'Resource model', + 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.'), '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. " \ -- cgit v1.2.3 From e068962cca72f8936f34e2f81555ef93214e05fc Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Tue, 29 Jun 2010 17:00:29 +0300 Subject: Document UI: rename the parent_id of a dir . bzr revid: p_christ@hol.gr-20100629140029-fnx876jkkezchc3j --- addons/document/document_directory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/document/document_directory.py') diff --git a/addons/document/document_directory.py b/addons/document/document_directory.py index 2872491129d..a464ca61247 100644 --- a/addons/document/document_directory.py +++ b/addons/document/document_directory.py @@ -43,7 +43,7 @@ class document_directory(osv.osv): 'user_id': fields.many2one('res.users', 'Owner'), 'storage_id': fields.many2one('document.storage', 'Storage'), 'group_ids': fields.many2many('res.groups', 'document_directory_group_rel', 'item_id', 'group_id', 'Groups'), - 'parent_id': fields.many2one('document.directory', 'Parent Item', select=1), + 'parent_id': fields.many2one('document.directory', 'Parent Directory', select=1), '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'), -- cgit v1.2.3 From 74d60c861f8a8ea7bc04a1dd135db699a94bdbc3 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Tue, 29 Jun 2010 17:05:19 +0300 Subject: Document: the node context shouldn't contain 'lang' Node context should be as neutral as possible, in order to help caching. bzr revid: p_christ@hol.gr-20100629140519-fgxcr2wm5ctg8ywl --- addons/document/document_directory.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'addons/document/document_directory.py') diff --git a/addons/document/document_directory.py b/addons/document/document_directory.py index a464ca61247..1b62418106c 100644 --- a/addons/document/document_directory.py +++ b/addons/document/document_directory.py @@ -195,17 +195,8 @@ class document_directory(osv.osv): """ if not context: context = {} - lang = context.get('lang',False) - if not lang: - user = self.pool.get('res.users').browse(cr, uid, uid) - lang = user.context_lang - context['lang'] = lang - try: #just instrumentation - return nodes.get_node_context(cr, uid, context).get_uri(cr, uri) - except Exception,e: - print "exception: ",e - raise + return nodes.get_node_context(cr, uid, context).get_uri(cr, uri) def _locate_child(self, cr, uid, root_id, uri,nparent, ncontext): -- cgit v1.2.3 From 03865bc917b6fa7ee3e3964411722ccdc75b52c2 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Fri, 9 Jul 2010 01:50:42 +0300 Subject: Document: Less dir, storage options, cleanup views. The 'virtual' storage is now hidden. An extra 'db64' type, hidden, is supported in the code, for v5-compatible databases (until we migrate the db_datas column of them). The 'at_record' directory type is gone. A module in extra-addons will permit the compatible behaviour, for those experts. bzr revid: p_christ@hol.gr-20100708225042-fp3zcwmw4zp3ee04 --- addons/document/document_directory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/document/document_directory.py') diff --git a/addons/document/document_directory.py b/addons/document/document_directory.py index 1b62418106c..9913946eee4 100644 --- a/addons/document/document_directory.py +++ b/addons/document/document_directory.py @@ -50,7 +50,7 @@ class document_directory(osv.osv): 'type': fields.selection([ ('directory','Static Directory'), ('ressource','Folders per resource'), - ('at_record','Single folder under resource')], + ], 'Type', required=True, select=1, help="Defines directory's behaviour."), -- cgit v1.2.3 From 0d6e0a9a0286a0b240e77f47f3b8b36aaaa2b1b9 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Fri, 9 Jul 2010 11:23:16 +0300 Subject: Document: support Moving of files. bzr revid: p_christ@hol.gr-20100709082316-d8qedrjabckypt88 --- addons/document/document_directory.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'addons/document/document_directory.py') diff --git a/addons/document/document_directory.py b/addons/document/document_directory.py index 9913946eee4..4d1079d6be9 100644 --- a/addons/document/document_directory.py +++ b/addons/document/document_directory.py @@ -270,6 +270,8 @@ class document_directory(osv.osv): raise osv.except_osv(_('ValidateError'), _('Directory name contains special characters!')) return super(document_directory,self).create(cr, uid, vals, context) + # TODO def unlink(... + document_directory() class document_directory_dctx(osv.osv): -- cgit v1.2.3 From 661a6818d89151b476c93af50be975da49e1459f Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Sun, 11 Jul 2010 17:25:27 +0300 Subject: Document API: framework for permisssion bits. The nodes may have extra permission attributes, rather than the ir.rule system. Store those bits in a 'uidperms' attribute of each node. bzr revid: p_christ@hol.gr-20100711142527-5o4v68yeuhgqvog4 --- addons/document/document_directory.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'addons/document/document_directory.py') diff --git a/addons/document/document_directory.py b/addons/document/document_directory.py index 4d1079d6be9..f340517be60 100644 --- a/addons/document/document_directory.py +++ b/addons/document/document_directory.py @@ -198,6 +198,22 @@ class document_directory(osv.osv): return nodes.get_node_context(cr, uid, context).get_uri(cr, uri) + def get_dir_permissions(self, cr, uid, ids ): + """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 7 def _locate_child(self, cr, uid, root_id, uri,nparent, ncontext): """ try to locate the node in uri, -- cgit v1.2.3 From a6010e22a2faba53f41d22068776360ac1545c55 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Sun, 11 Jul 2010 17:26:12 +0300 Subject: Document: implement permission checks based on group_ids. Conflicts: document/nodes.py bzr revid: p_christ@hol.gr-20100711142612-2erl7ia2j9fke1e0 --- addons/document/document_directory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/document/document_directory.py') diff --git a/addons/document/document_directory.py b/addons/document/document_directory.py index f340517be60..0685f5c08ff 100644 --- a/addons/document/document_directory.py +++ b/addons/document/document_directory.py @@ -213,7 +213,7 @@ class document_directory(osv.osv): if needs and not has: return 1 # still allow to descend into. else: - return 7 + return 15 def _locate_child(self, cr, uid, root_id, uri,nparent, ncontext): """ try to locate the node in uri, -- cgit v1.2.3 From 2d3d861a3e4317a71fb58307ac9d8a2866c6999c Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Tue, 13 Jul 2010 13:29:58 +0300 Subject: Document directory: "find_all" field for resource dirs. A (mis-)feature of the previous code was that in resource directories, it would only list attachments that would have those dirs as parents. This means that we couldn't have another categorisation, that would yield some of the same attachments. bzr revid: p_christ@hol.gr-20100713102958-nk40nckc41uxyzri --- addons/document/document_directory.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'addons/document/document_directory.py') diff --git a/addons/document/document_directory.py b/addons/document/document_directory.py index 0685f5c08ff..f5b9202fc8e 100644 --- a/addons/document/document_directory.py +++ b/addons/document/document_directory.py @@ -57,6 +57,9 @@ class document_directory(osv.osv): 'ressource_type_id': fields.many2one('ir.model', 'Resource model', 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', help="If you put an object here, this directory template will appear bellow all of these objects. " \ "Don't put a parent directory if you select a parent model."), @@ -103,6 +106,7 @@ class document_directory(osv.osv): 'type': lambda *args: 'directory', 'ressource_id': lambda *a: 0, 'storage_id': _get_def_storage, + 'resource_find_all': True, } _sql_constraints = [ ('dirname_uniq', 'unique (name,parent_id,ressource_id,ressource_parent_type_id)', 'The directory name must be unique !'), -- cgit v1.2.3