Commit 369090b2 authored by Jérome Perrin's avatar Jérome Perrin

always add fields from default field library, even if we have perfect matches.

if no property "erp5_default_field_library_path" is defined, fallback to erp5_core.Base_viewFieldLibrary


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@16405 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9ab95b31
...@@ -584,7 +584,9 @@ class ERP5Form(ZMIForm, ZopePageTemplate): ...@@ -584,7 +584,9 @@ class ERP5Form(ZMIForm, ZopePageTemplate):
portal = portal_url.getPortalObject() portal = portal_url.getPortalObject()
portal_skins = getToolByName(self, 'portal_skins') portal_skins = getToolByName(self, 'portal_skins')
default_field_library_path = portal.getProperty('erp5_default_field_library_path', None) default_field_library_path = portal.getProperty(
'erp5_default_field_library_path',
'erp5_core.Base_viewFieldLibrary')
if (not default_field_library_path or if (not default_field_library_path or
len(default_field_library_path.split('.'))!=2): len(default_field_library_path.split('.'))!=2):
return return
...@@ -595,21 +597,24 @@ class ERP5Form(ZMIForm, ZopePageTemplate): ...@@ -595,21 +597,24 @@ class ERP5Form(ZMIForm, ZopePageTemplate):
default_field_library = getattr(skinfolder, form_id, None) default_field_library = getattr(skinfolder, form_id, None)
if default_field_library is None: if default_field_library is None:
return return
for i in default_field_library.objectValues():
if not default_field_library_path in form_order: field_meta_type, proxy_flag = get_field_meta_type_and_proxy_flag(i)
for i in default_field_library.objectValues(): if meta_type==field_meta_type:
field_meta_type, proxy_flag = get_field_meta_type_and_proxy_flag(i) if proxy_flag:
if meta_type==field_meta_type: field_meta_type = '%s(Proxy)' % field_meta_type
if proxy_flag: matched_item = {'form_id':form_id,
field_meta_type = '%s(Proxy' % field_meta_type 'field_type':field_meta_type,
matched_item = {'form_id':form_id, 'field_object':i,
'field_type':field_meta_type, 'proxy_flag':proxy_flag,
'field_object':i, 'matched_rate':0
'proxy_flag':proxy_flag, }
'matched_rate':0 if not default_field_library_path in form_order:
}
matched_append(default_field_library_path, matched_append(default_field_library_path,
matched_item) matched_item)
if not default_field_library_path in \
perfect_matched_form_order:
perfect_matched_append(default_field_library_path,
matched_item)
id_ = field.getId() id_ = field.getId()
meta_type = field.meta_type meta_type = field.meta_type
...@@ -649,6 +654,7 @@ class ERP5Form(ZMIForm, ZopePageTemplate): ...@@ -649,6 +654,7 @@ class ERP5Form(ZMIForm, ZopePageTemplate):
if perfect_matched: if perfect_matched:
perfect_matched_form_order.sort() perfect_matched_form_order.sort()
add_default_field_library()
return perfect_matched_form_order, perfect_matched return perfect_matched_form_order, perfect_matched
form_order.sort() form_order.sort()
...@@ -783,7 +789,8 @@ def get_field_meta_type_and_proxy_flag(field): ...@@ -783,7 +789,8 @@ def get_field_meta_type_and_proxy_flag(field):
try: try:
return field.getRecursiveTemplateField().meta_type, True return field.getRecursiveTemplateField().meta_type, True
except AttributeError: except AttributeError:
raise AttributeError, 'The proxy target of %s field does not exists. Please check the field setting.' % field.getId() raise AttributeError, 'The proxy target of %s field does not '\
'exists. Please check the field setting.' % field.getId()
else: else:
return field.meta_type, False return field.meta_type, False
......
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