Commit 24017646 authored by Tomáš Peterka's avatar Tomáš Peterka

[erp5_core] Rename useful Script *_getListbox according to API naming conventions

parent 207bf91e
...@@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
<tal:block tal:define="form_action string:Base_doSelect; <tal:block tal:define="form_action string:Base_doSelect;
form_id form/id; form_id form/id;
list_mode python: True; list_mode python: True;
listmode_default_listbox python: here.ERP5Site_getListbox(form=form); listmode_default_listbox python: form.Form_getListbox();
selection_name listmode_default_listbox/selection_name; selection_name listmode_default_listbox/selection_name;
selection_index request/selection_index | python:0; selection_index request/selection_index | python:0;
dummy python: selection_name and request.set('selection_name', selection_name); dummy python: selection_name and request.set('selection_name', selection_name);
......
...@@ -2,26 +2,30 @@ ...@@ -2,26 +2,30 @@
# Christophe Dumez <christophe@nexedi.com> # Christophe Dumez <christophe@nexedi.com>
# This script should be used to detect a listbox without having to name it "listbox" # This script should be used to detect a listbox without having to name it "listbox"
if form is None:
form=context
if form.meta_type != 'ERP5 Form':
return None
# XXX We should not use meta_type properly,
# XXX We need to discuss this problem.(yusei)
def isListBox(field): def isListBox(field):
if field.meta_type=='ListBox': if field.meta_type == "ListBox":
return True return True
elif field.meta_type=='ProxyField': elif field.meta_type == "ProxyField":
template_field = field.getRecursiveTemplateField() template_field = field.getRecursiveTemplateField()
if template_field.meta_type=='ListBox': if template_field.meta_type == "ListBox":
return True return True
return False return False
if form is None:
form = context
if form.meta_type != 'ERP5 Form':
return None
if form.has_field('listbox'):
return form.get_field('listbox')
# we start with 'bottom' because most of the time # we start with 'bottom' because most of the time
# the listbox is there. # the listbox is there.
for group in ('bottom', 'center', 'left', 'right'): for group in ('bottom', 'center', 'left', 'right'):
for field in form.get_fields_in_group(group): for field in form.get_fields_in_group(group):
if isListBox(field) and not(field['hidden']) and field['enabled']: if (isListBox(field) and
return field not field.get_value('hidden') and
field.get_value('enabled')):
return field
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>ERP5Site_getListbox</string> </value> <value> <string>Form_getListbox</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
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