[IMP] 'more info' actions from relational fields conversion

link to ir.model.data if failing to link with database or external ids

bzr revid: xmo@openerp.com-20121004151753-wuyra1fjo31ur56g
This commit is contained in:
Xavier Morel
2012-10-04 17:17:53 +02:00
parent 8b4b31108d
commit 27f15d8af8
2 changed files with 14 additions and 9 deletions
+1
View File
@@ -1019,6 +1019,7 @@
<tree string="External Identifiers">
<field name="complete_name"/>
<field name="display_name"/>
<field name="res_id"/>
<field name="model" groups="base.group_no_one"/>
</tree>
</field>
+13 -9
View File
@@ -201,13 +201,16 @@ class ir_fields_converter(orm.Model):
if context is None: context = {}
id = None
warnings = []
extras = {'moreinfo': {
'type': 'ir.actions.act_window', 'target': 'new',
'res_model': column._obj, 'view_mode': 'tree,form',
'view_type': 'form',
'views': [(False, 'tree', (False, 'form'))],
'help': _(u"See all possible values")
}}
action = {'type': 'ir.actions.act_window', 'target': 'new',
'view_mode': 'tree,form', 'view_type': 'form',
'views': [(False, 'tree', (False, 'form'))],
'help': _(u"See all possible values")}
if subfield is None:
action['res_model'] = column._obj
elif subfield in ('id', '.id'):
action['res_model'] = 'ir.model.data'
action['domain'] = [('model', '=', column._obj)]
RelatedModel = self.pool[column._obj]
if subfield == '.id':
field_type = _(u"database id")
@@ -221,7 +224,7 @@ class ir_fields_converter(orm.Model):
# type error
raise ValueError(
_(u"Invalid database id '%s' for the field '%%(field)s'") % value,
extras)
{'moreinfo': action})
elif subfield == 'id':
field_type = _(u"external id")
if '.' in value:
@@ -252,7 +255,8 @@ class ir_fields_converter(orm.Model):
if id is None:
raise ValueError(
_(u"No matching record found for %(field_type)s '%(value)s' in field '%%(field)s'")
% {'field_type': field_type, 'value': value}, extras)
% {'field_type': field_type, 'value': value},
{'moreinfo': action})
return id, field_type, warnings
def _referencing_subfield(self, record):