Commit 1f0eba38 authored by Jérome Perrin's avatar Jérome Perrin

ERP5Form/hal_json_style: fix creation of ERP5 Form with newContent

This is not used directly when creating forms at the moment, but it's
useful for introspection to be able to create an instance of any portal
type with newContent()
parent d936b141
...@@ -1203,3 +1203,13 @@ return msg" ...@@ -1203,3 +1203,13 @@ return msg"
) )
result_dict = json.loads(result) result_dict = json.loads(result)
self.assertEqual(result_dict['title'], 'Foo_zhongwen') self.assertEqual(result_dict['title'], 'Foo_zhongwen')
class TestERP5FormAsPortalType(ERP5TypeTestCase):
def test_newContent(self):
# use portal_trash as a container as it allow anything
form = self.portal.portal_trash.newContent(
portal_type='ERP5 Form',
temp_object=True
)
self.assertEqual('ERP5 Form', form.getPortalType())
...@@ -633,7 +633,7 @@ class ERP5Form(Base, ZMIForm, ZopePageTemplate): ...@@ -633,7 +633,7 @@ class ERP5Form(Base, ZMIForm, ZopePageTemplate):
objectItems = ZMIForm.objectItems objectItems = ZMIForm.objectItems
objectValues = ZMIForm.objectValues objectValues = ZMIForm.objectValues
def __init__(self, id, title, unicode_mode=0, encoding='UTF-8', def __init__(self, id, title=None, unicode_mode=0, encoding='UTF-8',
stored_encoding='UTF-8'): stored_encoding='UTF-8'):
"""Initialize form. """Initialize form.
id -- id of form id -- id of form
...@@ -643,7 +643,7 @@ class ERP5Form(Base, ZMIForm, ZopePageTemplate): ...@@ -643,7 +643,7 @@ class ERP5Form(Base, ZMIForm, ZopePageTemplate):
encoding, stored_encoding, encoding, stored_encoding,
unicode_mode) unicode_mode)
self.id = id self.id = id
self.title = title self.title = title or id
self.row_length = 4 self.row_length = 4
self.group_list = ["left", "right", "center", "bottom", "hidden"] self.group_list = ["left", "right", "center", "bottom", "hidden"]
groups = {} groups = {}
......
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