Commit 48a8f054 authored by Julien Muchembled's avatar Julien Muchembled

Fix initialization of portal types that are defined outside Types Tool

This fixes TestSolvingPackingList

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@39623 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent dc7236a7
...@@ -1797,7 +1797,7 @@ class TestSolvingPackingList(TestPackingListMixin, ERP5TypeTestCase): ...@@ -1797,7 +1797,7 @@ class TestSolvingPackingList(TestPackingListMixin, ERP5TypeTestCase):
id=solver_id, id=solver_id,
tested_property_list=tested_property_list, tested_property_list=tested_property_list,
automatic_solver=1, automatic_solver=1,
type_factory_method_id='add%s' % solver_class, type_class=solver_class,
type_group_list=('target_solver',), type_group_list=('target_solver',),
) )
solver.setCriterion(property='portal_type', solver.setCriterion(property='portal_type',
......
...@@ -104,23 +104,21 @@ def generatePortalTypeClass(portal_type_name): ...@@ -104,23 +104,21 @@ def generatePortalTypeClass(portal_type_name):
from Products.ERP5.ERP5Site import getSite from Products.ERP5.ERP5Site import getSite
site = getSite() site = getSite()
types_tool = site.portal_types
portal_type = None
mixin_list = []
interface_list = []
accessor_holder_list = [] accessor_holder_list = []
try: # Do not use __getitem__ (or _getOb) because portal_type may exist in a
portal_type = types_tool[portal_type_name] # type provider other than Types Tool.
except KeyError: portal_type = getattr(site.portal_types, portal_type_name, None)
if portal_type is None:
# Try to figure out a coresponding document class from the document side. # Try to figure out a coresponding document class from the document side.
# This can happen when calling newTempAmount for instance: # This can happen when calling newTempAmount for instance:
# Amount has no corresponding Base Type and will never have one # Amount has no corresponding Base Type and will never have one
# But the semantic of newTempXXX requires us to create an # But the semantic of newTempXXX requires us to create an
# object using the Amount Document, so we promptly do it: # object using the Amount Document, so we promptly do it:
type_class = portal_type_name.replace(' ', '') type_class = portal_type_name.replace(' ', '')
mixin_list = []
if portal_type is not None: interface_list = []
else:
# type_class has a compatibility getter that should return # type_class has a compatibility getter that should return
# something even if the field is not set (i.e. Base Type object # something even if the field is not set (i.e. Base Type object
# was not migrated yet) # was not migrated yet)
......
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