Commit 7bea7bb2 authored by Arnaud Fontaine's avatar Arnaud Fontaine

newTemp*() deprecation (1bce8563, 04b49859): Remove hack in...

newTemp*() deprecation (1bce8563, 04b49859): Remove hack in NotificationTool.sendMessage() not working with ZODB Components.

When a Portal Type could not be found, sendMessage() was creating a temp_object
instead (even when passing store_as_event=True) by calling newTempPORTAL_TYPE()
and thus assuming a filesystem Document. So from now on, Portal Type must be
available and thus sendMessage() will fail otherwise. Moreover, if store_as_event
is True, this will no longer create a temp_object silently as it used to when
the Portal Type is not available.

This moves Mail Message Portal Type from erp5_crm to erp5_base as MailMessage_send
(send() being called directly from sendMessage() for temp_object) is already
in erp5_base. As this is only to allow creating temp_object, leave its Actions,
Workflows and Constraint relying on erp5_crm API as they are.
parent a0c2b666
...@@ -53,6 +53,9 @@ ...@@ -53,6 +53,9 @@
<portal_type id="Geographical Area"> <portal_type id="Geographical Area">
<item>Geographical Location</item> <item>Geographical Location</item>
</portal_type> </portal_type>
<portal_type id="Mail Message">
<item>Embedded File</item>
</portal_type>
<portal_type id="Notification Message"> <portal_type id="Notification Message">
<item>Role Definition</item> <item>Role Definition</item>
</portal_type> </portal_type>
......
...@@ -39,7 +39,9 @@ ...@@ -39,7 +39,9 @@
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
<value> <string>A Mail Message is an event which can be used to keep track of incoming emails (ex. support requests) or to create outgoing emails (for example in a campaign).</string> </value> <value> <string>A Mail Message is an event which can be used to keep track of incoming emails (ex. support requests) or to create outgoing emails (for example in a campaign).\n
\n
Without erp5_crm Business Template, only temp_object can be created.</string> </value>
</item> </item>
<item> <item>
<key> <string>factory</string> </key> <key> <string>factory</string> </key>
......
...@@ -32,6 +32,7 @@ Delivery Type | Action Information ...@@ -32,6 +32,7 @@ Delivery Type | Action Information
Delivery Type | Role Information Delivery Type | Role Information
Embedded Folder | Embedded File Embedded Folder | Embedded File
Geographical Area | Geographical Location Geographical Area | Geographical Location
Mail Message | Embedded File
Notification Message Module | Notification Message Notification Message Module | Notification Message
Notification Message | Role Definition Notification Message | Role Definition
Order Builder | Base Variant Movement Group Order Builder | Base Variant Movement Group
......
...@@ -31,6 +31,7 @@ Geographical Location ...@@ -31,6 +31,7 @@ Geographical Location
Image Image
Invoice Movement Group Invoice Movement Group
Link Link
Mail Message
Mapped Property Mapped Property
Monthly Range Movement Group Monthly Range Movement Group
Nested Line Movement Group Nested Line Movement Group
......
...@@ -21,9 +21,6 @@ ...@@ -21,9 +21,6 @@
<portal_type id="Letter"> <portal_type id="Letter">
<item>Embedded File</item> <item>Embedded File</item>
</portal_type> </portal_type>
<portal_type id="Mail Message">
<item>Embedded File</item>
</portal_type>
<portal_type id="Meeting"> <portal_type id="Meeting">
<item>Event Path</item> <item>Event Path</item>
</portal_type> </portal_type>
......
mimetypes_registry mimetypes_registry
portal_types/Mail Message
\ No newline at end of file
...@@ -12,7 +12,6 @@ Event Module | Site Message ...@@ -12,7 +12,6 @@ Event Module | Site Message
Event Module | Visit Event Module | Visit
Event Module | Web Message Event Module | Web Message
Letter | Embedded File Letter | Embedded File
Mail Message | Embedded File
Meeting Module | Meeting Meeting Module | Meeting
Meeting | Event Path Meeting | Event Path
Preference | Support Request Preference | Support Request
......
...@@ -5,7 +5,6 @@ Event Module ...@@ -5,7 +5,6 @@ Event Module
Event Path Event Path
Fax Message Fax Message
Letter Letter
Mail Message
Meeting Meeting
Meeting Module Meeting Module
Note Note
......
...@@ -351,17 +351,18 @@ class NotificationTool(BaseTool): ...@@ -351,17 +351,18 @@ class NotificationTool(BaseTool):
if event_keyword_argument_dict is None: if event_keyword_argument_dict is None:
event_keyword_argument_dict = {} event_keyword_argument_dict = {}
for notifier in notifier_list: for notifier in notifier_list:
if notifier in available_notifier_list: if notifier not in available_notifier_list:
event = portal.getDefaultModule(notifier).newContent(portal_type=notifier, raise TypeError("%r not in available Notifiers %r" %
temp_object=not store_as_event, (notifier, available_notifier_list))
# If it is not going to be stored, no need to create it in a specific
# Module, especially considering that it may not be available such as
# `Event Module` (erp5_crm) for `Mail Message` (erp5_base) notifier
if not store_as_event:
event = portal.newContent(portal_type=notifier, temp_object=True,
**event_keyword_argument_dict) **event_keyword_argument_dict)
else: else:
# portal type does not exist, likely erp5_crm is not installed. Try to event = portal.getDefaultModule(notifier).newContent(portal_type=notifier,
# import the class with the same name. **event_keyword_argument_dict)
from Products.ERP5Type import Document as document_module
constructor = getattr(document_module,
'newTemp%s' % notifier.replace(' ', ''))
event = constructor(self, '_', **event_keyword_argument_dict)
event.setSourceValue(from_person) event.setSourceValue(from_person)
event.setDestinationValueList(to_person_list) event.setDestinationValueList(to_person_list)
......
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