Commit 112bc22b authored by Arnaud Fontaine's avatar Arnaud Fontaine

Folder: Allow to create temp_objects anywhere, without checking if it's in...

Folder: Allow to create temp_objects anywhere, without checking if it's in allowed types for that Portal Type.

Until now, creating a temp_object with newContent() required for the temp_object
to be in allowed types. However, this was inconsistent with (now deprecated)
newTemp*() functions (calling directly constructInstance()) not having such
limitations.

Besides lifting such limitation being needed to properly replace newTemp*() calls,
portal_trash.newContent() pattern is already commonly used used here meaning there
is a real use case.

This also fixes testBanking* failures: newTempCashDeliveryLine() created objects
on 'Cash Inventory' and latter call Delivery.isAccountable() which does not exist on
portal_trash.

See also:
  04b49859
  03678123d60c07d58638a16433d599ae04b54194
parent accf13dd
...@@ -63,7 +63,7 @@ class CashInventory(Inventory, BankingOperation): ...@@ -63,7 +63,7 @@ class CashInventory(Inventory, BankingOperation):
setting another kind of temp delivery line. setting another kind of temp delivery line.
""" """
def newTempCashDeliveryLine(self, inventory_id): def newTempCashDeliveryLine(self, inventory_id):
return self.getPortalObject().portal_trash.newContent( return self.newContent(
portal_type='Cash Delivery Line', portal_type='Cash Delivery Line',
temp_object=True, temp_object=True,
id=inventory_id) id=inventory_id)
......
...@@ -201,10 +201,9 @@ class FolderMixIn(ExtensionClass.Base): ...@@ -201,10 +201,9 @@ class FolderMixIn(ExtensionClass.Base):
portal_type = allowed_content_type_list[0].id portal_type = allowed_content_type_list[0].id
else: else:
raise ValueError('Creation disallowed') raise ValueError('Creation disallowed')
else: elif not temp_object:
type_info = pt.getTypeInfo(container) type_info = pt.getTypeInfo(container)
if type_info is not None and not type_info.allowType(portal_type) and \ if type_info is not None and not type_info.allowType(portal_type):
'portal_trash' not in container.getPhysicalPath():
raise ValueError('Disallowed subobject type: %s on %r' % (portal_type, container)) raise ValueError('Disallowed subobject type: %s on %r' % (portal_type, container))
type_info = pt.getTypeInfo(portal_type) type_info = pt.getTypeInfo(portal_type)
......
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