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 @@
<portal_type id="Geographical Area">
<item>Geographical Location</item>
</portal_type>
<portal_type id="Mail Message">
<item>Embedded File</item>
</portal_type>
<portal_type id="Notification Message">
<item>Role Definition</item>
</portal_type>
......
......@@ -39,7 +39,9 @@
</item>
<item>
<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>
<key> <string>factory</string> </key>
......
......@@ -32,6 +32,7 @@ Delivery Type | Action Information
Delivery Type | Role Information
Embedded Folder | Embedded File
Geographical Area | Geographical Location
Mail Message | Embedded File
Notification Message Module | Notification Message
Notification Message | Role Definition
Order Builder | Base Variant Movement Group
......
......@@ -31,6 +31,7 @@ Geographical Location
Image
Invoice Movement Group
Link
Mail Message
Mapped Property
Monthly Range Movement Group
Nested Line Movement Group
......
......@@ -21,9 +21,6 @@
<portal_type id="Letter">
<item>Embedded File</item>
</portal_type>
<portal_type id="Mail Message">
<item>Embedded File</item>
</portal_type>
<portal_type id="Meeting">
<item>Event Path</item>
</portal_type>
......
mimetypes_registry
\ No newline at end of file
mimetypes_registry
portal_types/Mail Message
\ No newline at end of file
......@@ -12,7 +12,6 @@ Event Module | Site Message
Event Module | Visit
Event Module | Web Message
Letter | Embedded File
Mail Message | Embedded File
Meeting Module | Meeting
Meeting | Event Path
Preference | Support Request
......
......@@ -5,7 +5,6 @@ Event Module
Event Path
Fax Message
Letter
Mail Message
Meeting
Meeting Module
Note
......
......@@ -351,17 +351,18 @@ class NotificationTool(BaseTool):
if event_keyword_argument_dict is None:
event_keyword_argument_dict = {}
for notifier in notifier_list:
if notifier in available_notifier_list:
event = portal.getDefaultModule(notifier).newContent(portal_type=notifier,
temp_object=not store_as_event,
**event_keyword_argument_dict)
if notifier not in available_notifier_list:
raise TypeError("%r not in available Notifiers %r" %
(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)
else:
# portal type does not exist, likely erp5_crm is not installed. Try to
# import the class with the same name.
from Products.ERP5Type import Document as document_module
constructor = getattr(document_module,
'newTemp%s' % notifier.replace(' ', ''))
event = constructor(self, '_', **event_keyword_argument_dict)
event = portal.getDefaultModule(notifier).newContent(portal_type=notifier,
**event_keyword_argument_dict)
event.setSourceValue(from_person)
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