Commit 6e615c84 authored by Jérome Perrin's avatar Jérome Perrin Committed by Xiaowu Zhang

relationfield: display title when using 'title_or_reference' catalog

index

we have a scriptable key for title_or_reference :
from Products.ZSQLCatalog.SQLCatalog import Query, ComplexQuery

query = ComplexQuery(
  Query(title=value),
  Query(reference=value),
  operator="OR")
return query
parent 91861bd8
...@@ -687,6 +687,8 @@ class MultiRelationStringFieldValidator(Validator.LinesValidator): ...@@ -687,6 +687,8 @@ class MultiRelationStringFieldValidator(Validator.LinesValidator):
related_object = portal_catalog.getObject(relation_uid) related_object = portal_catalog.getObject(relation_uid)
if related_object is not None: if related_object is not None:
display_text = str(related_object.getProperty(catalog_index)) display_text = str(related_object.getProperty(catalog_index))
if catalog_index == 'title_or_reference':
display_text = related_object.getTitle()
menu_item_list.append((display_text, relation_uid)) menu_item_list.append((display_text, relation_uid))
relation_editor_list.append( relation_editor_list.append(
( (
...@@ -705,6 +707,8 @@ class MultiRelationStringFieldValidator(Validator.LinesValidator): ...@@ -705,6 +707,8 @@ class MultiRelationStringFieldValidator(Validator.LinesValidator):
try: try:
related_object = portal_catalog.getObject(relation_uid) related_object = portal_catalog.getObject(relation_uid)
display_text = str(related_object.getProperty(catalog_index)) display_text = str(related_object.getProperty(catalog_index))
if catalog_index == 'title_or_reference':
display_text = related_object.getTitle()
except ValueError: except ValueError:
if relation_uid.startswith(NEW_CONTENT_PREFIX): if relation_uid.startswith(NEW_CONTENT_PREFIX):
portal_type = relation_uid[len(NEW_CONTENT_PREFIX):] portal_type = relation_uid[len(NEW_CONTENT_PREFIX):]
...@@ -772,4 +776,4 @@ class MultiRelationStringField(ZMIField): ...@@ -772,4 +776,4 @@ class MultiRelationStringField(ZMIField):
# Register get_value # Register get_value
from Products.ERP5Form.ProxyField import registerOriginalGetValueClassAndArgument from Products.ERP5Form.ProxyField import registerOriginalGetValueClassAndArgument
registerOriginalGetValueClassAndArgument(MultiRelationStringField, 'items') registerOriginalGetValueClassAndArgument(MultiRelationStringField, 'items')
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment