[IMP]: document: Improvement in name field for resource directory, made it m2o for better usability
bzr revid: rpa@tinyerp.com-20100408062316-gubx9qin3p9r66in
This commit is contained in:
parent
f7b0870f90
commit
29f79a6e65
|
@ -52,7 +52,7 @@ class document_directory(osv.osv):
|
|||
'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."),
|
||||
'resource_field': fields.char('Name field',size=32,help='Field to be used as name on resource directories. If empty, the "name" will be used.'),
|
||||
'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. " \
|
||||
"Don't put a parent directory if you select a parent model."),
|
||||
|
@ -61,10 +61,12 @@ class document_directory(osv.osv):
|
|||
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'),
|
||||
}
|
||||
|
||||
|
||||
def _get_root_directory(self, cr,uid, context=None):
|
||||
objid=self.pool.get('ir.model.data')
|
||||
try:
|
||||
mid = objid._get_id(cr, uid, 'document', 'dir_root')
|
||||
mid = objid._get_id(cr, uid, 'document', 'dir_root')
|
||||
if not mid:
|
||||
return False
|
||||
root_id = objid.read(cr, uid, mid, ['res_id'])['res_id']
|
||||
|
|
|
@ -71,7 +71,7 @@
|
|||
<newline/>
|
||||
<field name="domain" attrs="{'required': [('type','=','ressource')], 'readonly': [('type','=','static')]}"/>
|
||||
<field name="ressource_tree"/>
|
||||
<field name="resource_field"/>
|
||||
<field name="resource_field" domain="[('model_id','=',ressource_type_id), ('ttype', 'in', ('char', 'selection', 'date', 'datetime'))]"/>
|
||||
<field name="ressource_id" select="2" readonly="1"/>
|
||||
<field name="ressource_parent_type_id"/>
|
||||
</page>
|
||||
|
|
|
@ -320,7 +320,7 @@ class node_res_dir(node_class):
|
|||
self.content_length = 0
|
||||
self.res_model = dirr.ressource_type_id and dirr.ressource_type_id.model or False
|
||||
self.resm_id = dirr.ressource_id
|
||||
self.namefield = dirr.resource_field or 'name'
|
||||
self.namefield = dirr.resource_field.name or 'name'
|
||||
self.displayname = dirr.name
|
||||
# Important: the domain is evaluated using the *parent* dctx!
|
||||
self.domain = dirr.domain
|
||||
|
@ -508,7 +508,7 @@ class node_res_obj(node_class):
|
|||
where1 = where + [(obj._parent_name, '=', self.res_id)]
|
||||
resids = obj.search(cr,uid, where1, context=ctx)
|
||||
for bo in obj.browse(cr,uid,resids,context=ctx):
|
||||
namefield = directory.resource_field or 'name'
|
||||
namefield = directory.resource_field.name or 'name'
|
||||
if not bo:
|
||||
continue
|
||||
res_name = getattr(bo, namefield)
|
||||
|
|
Loading…
Reference in New Issue