Commit 1af22428 authored by Rafael Monnerat's avatar Rafael Monnerat

Merge branch 'master', remote-tracking branch 'origin' into rafael

parents 125c1c62 67bccd94
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>if content_type == \'text/html\':\n
mail_template = context.Event_viewHtmlMimeMessage\n
else:\n
mail_template = context.Event_viewMimeMessage\n
\n
for embedded_file in embedded_file_list:\n
mime_type, content = embedded_file.getMimeTypeAndContent()\n
name = embedded_file.getFilename()\n
\n
attachment_list.append({\'mime_type\':mime_type,\n
\'content\':content,\n
\'name\':name})\n
\n
# Allow to embed image in HTML by setting the relative URL of the image with FCKeditor\n
attachment_url = embedded_file.getRelativeUrl()\n
body = body.replace(\'src="%s"\' % attachment_url, \'src="cid:%s"\' % \'\'.join([\'%s\' % ord(i) for i in name]))\n
\n
multipart = mail_template.as_message(mfrom=from_url,\n
mto=to_url,\n
subject=subject,\n
body=body,\n
encoding=\'utf-8\')\n
for attachment_dict in attachment_list:\n
multipart.add_file(data=attachment_dict[\'content\'],\n
content_type=attachment_dict[\'mime_type\'],\n
filename=attachment_dict[\'name\'])\n
\n
return str(multipart)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>from_url, to_url, subject, body, content_type, attachment_list=[], embedded_file_list=[]</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_createMailMessageAsString</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -50,24 +50,45 @@ ...@@ -50,24 +50,45 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[ <value> <string>from email.utils import formataddr\n
portal = context.getPortalObject()\n
user_site_list = context.Baobab_getUserAssignedSiteList()\n event = portal.restrictedTraverse(event_relative_url)\n
if len(user_site_list)>0:\n \n
site = context.Baobab_getVaultSite(user_site_list[0])\n subject = event.getTitle()\n
site_url = site.getRelativeUrl()\n body = event.getTextContent()\n
context.setSite(site_url)\n sender = event.getSourceValue()\n
if sender is not None:\n
from_url = formataddr((sender.getTitle(), sender.getDefaultEmailText()))\n
]]></string> </value> else:\n
from_url = portal.portal_preferences.getPreferredEventSenderEmail()\n
\n
to_url = formataddr((context.getTitle(), context.getDefaultEmailText()))\n
\n
document_type_list = list(event.getPortalEmbeddedDocumentTypeList()) + list(event.getPortalDocumentTypeList())\n
embedded_file_list = event.getAggregateValueList(portal_type=document_type_list)\n
\n
content_type = event.getContentType()\n
mail_message = context.Base_createMailMessageAsString(from_url,\n
to_url,\n
subject,\n
body,\n
content_type,\n
attachment_list=[],\n
embedded_file_list=embedded_file_list)\n
\n
event.sendMailHostMessage(mail_message)\n
\n
if not event.hasData():\n
event.setData(mail_message)\n
</string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>**kw</string> </value> <value> <string>event_relative_url, **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>Person_init</string> </value> <value> <string>Entity_sendEmail</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -51,79 +51,76 @@ ...@@ -51,79 +51,76 @@
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>from email.utils import formataddr\n <value> <string>from email.utils import formataddr\n
from email import message_from_string\n
portal = context.getPortalObject()\n portal = context.getPortalObject()\n
\n \n
if body is None:\n use_activity = False\n
body = context.getTextContent() #XXX This does not support structured text format.\n mail_message = None\n
\n to_url_list = []\n
# Subject\n
if subject is None:\n
subject = context.getTitle()\n
\n
# From\n
if from_url is None:\n
sender = context.getSourceValue()\n
from_url = formataddr((sender.getTitle(), sender.getDefaultEmailText()))\n
\n \n
# Return-Path\n if not context.isTempDocument() and to_url is None:\n
if reply_url is None:\n use_activity = True\n
reply_url = portal.portal_preferences.getPreferredEventSenderEmail()\n
additional_headers = None\n
if reply_url:\n
additional_headers = {\'Return-Path\':reply_url}\n
\n \n
# To (multiple)\n
to_url_list = []\n
to_email_list = []\n
if to_url is None:\n if to_url is None:\n
for recipient in context.getDestinationValueList():\n if use_activity:\n
email = recipient.getDefaultEmailText()\n recipient = context.getDestinationValue()\n
if email:\n to_url_list.append(formataddr((recipient.getTitle(), recipient.getDefaultEmailText())))\n
if email not in to_email_list:\n else:\n
to_email_list = []\n
for recipient in context.getDestinationValueList():\n
email = recipient.getDefaultEmailText()\n
if email:\n
to_email_list.append(email)\n to_email_list.append(email)\n
to_url_list.append(formataddr((recipient.getTitle(), email)))\n to_url_list.append(formataddr((recipient.getTitle(), recipient.getDefaultEmailText())))\n
else:\n else:\n
raise ValueError, \'Recipient %s has no defined email\' % recipient\n raise ValueError("One email must be set to %s" % person.getRelativeUrl())\n
elif same_type(to_url, \'\'):\n else:\n
to_url_list.append(to_url)\n to_url_list.append(to_url)\n
\n \n
# Attachments\n if download or not use_activity:\n
if attachment_list is None:\n for to_url in to_url_list:\n
attachment_list = []\n body = body or context.getTextContent()\n
document_type_list = list(context.getPortalEmbeddedDocumentTypeList()) + list(context.getPortalDocumentTypeList())\n subject = subject or context.getTitle()\n
for attachment in context.getAggregateValueList(portal_type=document_type_list):\n
mime_type, content = attachment.getMimeTypeAndContent()\n
name = attachment.getFilename()\n
\n \n
attachment_list.append({\'mime_type\':mime_type,\n # From\n
\'content\':content,\n if from_url is None:\n
\'name\':name})\n sender = context.getSourceValue()\n
from_url = formataddr((sender.getTitle(), sender.getDefaultEmailText()))\n
\n \n
# Allow to embed image in HTML by setting the relative URL of the image with FCKeditor\n # Return-Path\n
attachment_url = attachment.getRelativeUrl()\n if reply_url is None:\n
body = body.replace(\'src="%s"\' % attachment_url, \'src="cid:%s"\' % \'\'.join([\'%s\' % ord(i) for i in name]))\n reply_url = portal.portal_preferences.getPreferredEventSenderEmail()\n
additional_headers = None\n
if reply_url:\n
additional_headers = {\'Return-Path\':reply_url}\n
\n \n
# Build message per destination\n # Attachments\n
mail_message = None\n if attachment_list is None:\n
if context.getContentType() == \'text/html\':\n attachment_list = []\n
mail_template = context.Event_viewHtmlMimeMessage\n document_type_list = list(context.getPortalEmbeddedDocumentTypeList()) + list(context.getPortalDocumentTypeList())\n
else:\n embedded_file_list = context.getAggregateValueList(portal_type=document_type_list)\n
mail_template = context.Event_viewMimeMessage\n \n
content_type = context.getContentType()\n
\n
mail_message = context.Base_createMailMessageAsString(from_url, \n
to_url,\n
subject,\n
body,\n
content_type,\n
attachment_list=attachment_list,\n
embedded_file_list=embedded_file_list)\n
\n \n
for to_url in to_url_list:\n context.edit(data=mail_message)\n
multipart = mail_template.as_message(mfrom=from_url,\n if not use_activity:\n
mto=to_url,\n context.activate(activity=\'SQLQueue\').sendMailHostMessage(mail_message)\n
subject=subject,\n
body=body,\n
encoding=\'utf-8\')\n
for attachment_dict in attachment_list:\n
multipart.add_file(data=attachment_dict[\'content\'],\n
content_type=attachment_dict[\'mime_type\'],\n
filename=attachment_dict[\'name\'])\n
mail_message = str(multipart)\n
context.activate(activity=\'SQLQueue\').sendMailHostMessage(mail_message)\n
\n \n
context.setData(mail_message)\n if use_activity:\n
uid_list = context.getDestinationUidList()\n
method_kw = dict(event_relative_url=context.getRelativeUrl(),\n
from_url=from_url)\n
portal.portal_catalog.searchAndActivate(method_id="Entity_sendEmail",\n
uid=uid_list,\n
method_kw=method_kw, **kw)\n
\n \n
# Transit event workflow\n # Transit event workflow\n
if context.getTypeInfo() is not None:\n if context.getTypeInfo() is not None:\n
......
1009 1015
\ No newline at end of file \ No newline at end of file
...@@ -94,7 +94,7 @@ feed_data = {}\n ...@@ -94,7 +94,7 @@ feed_data = {}\n
request = context.REQUEST\n request = context.REQUEST\n
\n \n
# required channel elements for RSS 2.0 specification\n # required channel elements for RSS 2.0 specification\n
required_field_list = (\'title\', \'description\', \'link\',)\n required_field_list = (\'title\', \'description\', \'link\')\n
\n \n
# required + optional channel elements\n # required + optional channel elements\n
allowed_field_list = (\'title\', \'description\', \'link\', \'author\', \n allowed_field_list = (\'title\', \'description\', \'link\', \'author\', \n
...@@ -103,6 +103,7 @@ allowed_field_list = (\'title\', \'description\', \'link\', \'author\', \n ...@@ -103,6 +103,7 @@ allowed_field_list = (\'title\', \'description\', \'link\', \'author\', \n
\n \n
# figure out which column is which, by using column titles\n # figure out which column is which, by using column titles\n
rss_column_mapping = {}\n rss_column_mapping = {}\n
\n
for index, column_item in enumerate(label_list):\n for index, column_item in enumerate(label_list):\n
column_header = column_item[1]\n column_header = column_item[1]\n
if column_header.lower() in allowed_field_list:\n if column_header.lower() in allowed_field_list:\n
...@@ -155,6 +156,7 @@ for line in line_list:\n ...@@ -155,6 +156,7 @@ for line in line_list:\n
items.append(rss_item_string)\n items.append(rss_item_string)\n
\n \n
feed_data[\'listItemInfos\'] = tuple(items)\n feed_data[\'listItemInfos\'] = tuple(items)\n
\n
return feed_data\n return feed_data\n
......
52 55
\ No newline at end of file \ No newline at end of file
...@@ -104,10 +104,6 @@ ...@@ -104,10 +104,6 @@
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>test_bp</string> </value> <value> <string>test_bp</string> </value>
</item> </item>
<item>
<key> <string>last_id</string> </key>
<value> <string>9</string> </value>
</item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
<value> <string>Business Process</string> </value> <value> <string>Business Process</string> </value>
......
...@@ -101,10 +101,6 @@ ...@@ -101,10 +101,6 @@
<key> <string>int_index</string> </key> <key> <string>int_index</string> </key>
<value> <int>1</int> </value> <value> <int>1</int> </value>
</item> </item>
<item>
<key> <string>last_id</string> </key>
<value> <string>2</string> </value>
</item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
<value> <string>Category</string> </value> <value> <string>Category</string> </value>
......
...@@ -93,10 +93,6 @@ ...@@ -93,10 +93,6 @@
<key> <string>int_index</string> </key> <key> <string>int_index</string> </key>
<value> <int>1</int> </value> <value> <int>1</int> </value>
</item> </item>
<item>
<key> <string>last_id</string> </key>
<value> <string>1</string> </value>
</item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
<value> <string>Category</string> </value> <value> <string>Category</string> </value>
......
...@@ -73,10 +73,6 @@ ...@@ -73,10 +73,6 @@
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>test_advanced_sale_invoice_builder</string> </value> <value> <string>test_advanced_sale_invoice_builder</string> </value>
</item> </item>
<item>
<key> <string>last_id</string> </key>
<value> <string>1</string> </value>
</item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
<value> <string>Delivery Builder</string> </value> <value> <string>Delivery Builder</string> </value>
......
...@@ -44,8 +44,7 @@ ...@@ -44,8 +44,7 @@
<key> <string>delivery_cell_separate_order</string> </key> <key> <string>delivery_cell_separate_order</string> </key>
<value> <value>
<tuple> <tuple>
<string>calculateAveragePrice</string> <string>calculateSeparatePrice</string>
<string>calculateAddQuantity</string>
</tuple> </tuple>
</value> </value>
</item> </item>
...@@ -75,10 +74,6 @@ ...@@ -75,10 +74,6 @@
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>test_advanced_sale_invoice_trade_model_builder</string> </value> <value> <string>test_advanced_sale_invoice_trade_model_builder</string> </value>
</item> </item>
<item>
<key> <string>last_id</string> </key>
<value> <string>2</string> </value>
</item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
<value> <string>Delivery Builder</string> </value> <value> <string>Delivery Builder</string> </value>
......
...@@ -73,10 +73,6 @@ ...@@ -73,10 +73,6 @@
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>test_sale_packing_list_builder</string> </value> <value> <string>test_sale_packing_list_builder</string> </value>
</item> </item>
<item>
<key> <string>last_id</string> </key>
<value> <string>1</string> </value>
</item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
<value> <string>Delivery Builder</string> </value> <value> <string>Delivery Builder</string> </value>
......
...@@ -153,10 +153,6 @@ ...@@ -153,10 +153,6 @@
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>test_trade_model_rule</string> </value> <value> <string>test_trade_model_rule</string> </value>
</item> </item>
<item>
<key> <string>last_id</string> </key>
<value> <string>3</string> </value>
</item>
<item> <item>
<key> <string>matching_property</string> </key> <key> <string>matching_property</string> </key>
<value> <value>
......
...@@ -123,10 +123,6 @@ ...@@ -123,10 +123,6 @@
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>test_stc</string> </value> <value> <string>test_stc</string> </value>
</item> </item>
<item>
<key> <string>last_id</string> </key>
<value> <string>2</string> </value>
</item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
<value> <string>Sale Trade Condition</string> </value> <value> <string>Sale Trade Condition</string> </value>
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
</item> </item>
<item> <item>
<key> <string>business_template_skin_layer_priority</string> </key> <key> <string>business_template_skin_layer_priority</string> </key>
<value> <float>10.0</float> </value> <value> <float>40.0</float> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
22 23
\ No newline at end of file \ No newline at end of file
...@@ -42,6 +42,7 @@ from email.mime.multipart import MIMEMultipart ...@@ -42,6 +42,7 @@ from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase from email.mime.base import MIMEBase
from email.mime.text import MIMEText from email.mime.text import MIMEText
from email import encoders, message_from_string from email import encoders, message_from_string
from DateTime import DateTime
def makeFilePath(name): def makeFilePath(name):
return os.path.join(os.path.dirname(__file__), 'test_data', 'crm_emails', name) return os.path.join(os.path.dirname(__file__), 'test_data', 'crm_emails', name)
...@@ -73,7 +74,6 @@ class BaseTestCRM(ERP5TypeTestCase): ...@@ -73,7 +74,6 @@ class BaseTestCRM(ERP5TypeTestCase):
for module_name in clear_module_name_list: for module_name in clear_module_name_list:
module = self.portal.unrestrictedTraverse(module_name) module = self.portal.unrestrictedTraverse(module_name)
module.manage_delObjects(list(module.objectIds())) module.manage_delObjects(list(module.objectIds()))
self.stepTic() self.stepTic()
super(BaseTestCRM, self).beforeTearDown() super(BaseTestCRM, self).beforeTearDown()
...@@ -82,7 +82,10 @@ class TestCRM(BaseTestCRM): ...@@ -82,7 +82,10 @@ class TestCRM(BaseTestCRM):
return "CRM" return "CRM"
def getBusinessTemplateList(self): def getBusinessTemplateList(self):
return ('erp5_base', return ('erp5_full_text_myisam_catalog',
'erp5_core_proxy_field_legacy',
'erp5_base',
'erp5_ingestion',
'erp5_crm',) 'erp5_crm',)
def test_Event_CreateRelatedEvent(self): def test_Event_CreateRelatedEvent(self):
...@@ -450,7 +453,9 @@ class TestCRMMailIngestion(BaseTestCRM): ...@@ -450,7 +453,9 @@ class TestCRMMailIngestion(BaseTestCRM):
def getBusinessTemplateList(self): def getBusinessTemplateList(self):
# Mail Ingestion must work with CRM alone. # Mail Ingestion must work with CRM alone.
return ('erp5_base', return ('erp5_core_proxy_field_legacy',
'erp5_full_text_myisam_catalog',
'erp5_base',
'erp5_ingestion', 'erp5_ingestion',
'erp5_ingestion_mysql_innodb_catalog', 'erp5_ingestion_mysql_innodb_catalog',
'erp5_crm', 'erp5_crm',
...@@ -846,7 +851,6 @@ class TestCRMMailSend(BaseTestCRM): ...@@ -846,7 +851,6 @@ class TestCRMMailSend(BaseTestCRM):
def afterSetUp(self): def afterSetUp(self):
super(TestCRMMailSend, self).afterSetUp() super(TestCRMMailSend, self).afterSetUp()
portal = self.portal portal = self.portal
# create customer organisation and person # create customer organisation and person
portal.organisation_module.newContent( portal.organisation_module.newContent(
id='customer', id='customer',
...@@ -1189,7 +1193,6 @@ class TestCRMMailSend(BaseTestCRM): ...@@ -1189,7 +1193,6 @@ class TestCRMMailSend(BaseTestCRM):
text_content='This is an advertisement mail.') text_content='This is an advertisement mail.')
mail_text = event.send(download=True) mail_text = event.send(download=True)
# Check mail text. # Check mail text.
message = message_from_string(mail_text) message = message_from_string(mail_text)
part = None part = None
...@@ -1673,6 +1676,55 @@ class TestCRMMailSend(BaseTestCRM): ...@@ -1673,6 +1676,55 @@ class TestCRMMailSend(BaseTestCRM):
transaction.commit() transaction.commit()
self.tic() self.tic()
def test_MailMessage_Event_send_generate_activity_list(self):
"""
Check that after post a Mail Message, the activities are generated
correctly
"""
person = self.portal.person_module.newContent(portal_type="Person")
person.edit(default_email_text="test@test.com", title="test%s" % person.getId())
self.stepTic()
mail_message = self.portal.event_module.newContent(portal_type="Mail Message")
relative_url_list = [z.getRelativeUrl() for z in self.portal.person_module.searchFolder()]
mail_message.setDestinationList(relative_url_list)
mail_message.setSource(relative_url_list[0])
mail_text_content = "Body Text Content"
mail_message.setTextContent(mail_text_content)
self.portal.portal_workflow.doActionFor(mail_message, "start_action")
self.stepTic()
mail_message.Event_send(packet_size=2)
import transaction
transaction.commit()
portal_activities = self.portal.portal_activities
message_list = [i for i in portal_activities.getMessageList() \
if i.kw.has_key("event_relative_url")]
try:
self.assertEquals(2, len(message_list))
finally:
self.stepTic()
last_message = self.portal.MailHost._last_message
self.assertTrue(mail_text_content in last_message[-1])
message = message_from_string(last_message[-1])
last_message_date = DateTime(message.get("Date"))
self.assertTrue(last_message_date.isCurrentDay())
def test_MailMessage_Event_send_simple_case(self):
"""
Check that the script Event_send send one email passing all parameters directly
from_url, to_url, reply_url, subject, body, attachment_format, attachment_list
"""
mail_message = self.portal.event_module.newContent(portal_type="Mail Message")
self.stepTic()
mail_message.Event_send(from_url='FG ER <eee@eee.com>',
to_url='Expert User <expert@in24.test>',
subject="Simple Case",
body="Body Simple Case",
attachment_list=[])
self.stepTic()
last_message = self.portal.MailHost._last_message[-1]
self.assertTrue("Body Simple Case" in last_message)
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestCRM)) suite.addTest(unittest.makeSuite(TestCRM))
......
...@@ -76,6 +76,12 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -76,6 +76,12 @@ class TestERP5Credential(ERP5TypeTestCase):
if 'MailHost' in self.portal.objectIds(): if 'MailHost' in self.portal.objectIds():
self.portal.manage_delObjects(['MailHost']) self.portal.manage_delObjects(['MailHost'])
self.portal._setObject('MailHost', DummyMailHost('MailHost')) self.portal._setObject('MailHost', DummyMailHost('MailHost'))
system_preference = self.getPreferenceTool().getActiveSystemPreference()
if system_preference is None:
system_preference = self.portal.portal_preferences.newContent(
portal_type='System Preference')
system_preference.enable()
system_preference.edit(preferred_event_sender_email=['Sample s@s.com',])
@reindex @reindex
def enableAlarm(self): def enableAlarm(self):
......
...@@ -1484,7 +1484,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): ...@@ -1484,7 +1484,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
def test_03_WebSection_getDocumentValueListSecurity(self): def test_03_WebSection_getDocumentValueListSecurity(self):
""" Test WebSection_getDocumentValueList behaviour and security""" """ Test WebSection_getDocumentValueList behaviour and security"""
self.login('admin') self.login('admin')
site = self.web_site_module.newContent(portal_type='Web Site', site = self.portal.web_site_module.newContent(portal_type='Web Site',
id='site') id='site')
site.publish() site.publish()
...@@ -1620,7 +1620,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): ...@@ -1620,7 +1620,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
def test_04_ExpireUserAction(self): def test_04_ExpireUserAction(self):
""" Test the expire user action""" """ Test the expire user action"""
self.login('admin') self.login('admin')
site = self.web_site_module.newContent(portal_type='Web Site', id='site') site = self.portal.web_site_module.newContent(portal_type='Web Site', id='site')
# create websections in a site and in anothers web sections # create websections in a site and in anothers web sections
section_1 = site.newContent(portal_type='Web Section', id='section_1') section_1 = site.newContent(portal_type='Web Section', id='section_1')
...@@ -1650,7 +1650,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): ...@@ -1650,7 +1650,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
def test_05_createWebSite(self): def test_05_createWebSite(self):
""" Test to create or clone web sites with many users """ """ Test to create or clone web sites with many users """
self.login('admin') self.login('admin')
web_site_module = self.web_site_module web_site_module = self.portal.web_site_module
# test for admin # test for admin
try: try:
...@@ -1673,7 +1673,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): ...@@ -1673,7 +1673,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
def test_06_createWebSection(self): def test_06_createWebSection(self):
""" Test to create or clone web sections with many users """ """ Test to create or clone web sections with many users """
self.login('admin') self.login('admin')
site = self.web_site_module.newContent(portal_type='Web Site', id='site') site = self.portal.web_site_module.newContent(portal_type='Web Site', id='site')
# test for admin # test for admin
try: try:
...@@ -1818,7 +1818,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): ...@@ -1818,7 +1818,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
project.validate() project.validate()
self.stepTic() self.stepTic()
website = self.web_site_module.newContent(portal_type='Web Site', website = self.portal.web_site_module.newContent(portal_type='Web Site',
id='site') id='site')
website.publish() website.publish()
website.setMembershipCriterionBaseCategory('follow_up') website.setMembershipCriterionBaseCategory('follow_up')
...@@ -1856,7 +1856,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): ...@@ -1856,7 +1856,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
Test that by default Anonymous User cannot access Web Site Module Test that by default Anonymous User cannot access Web Site Module
""" """
self.logout() self.logout()
self.assertRaises(Unauthorized, self.web_site_module.view) self.assertRaises(Unauthorized, self.portal.web_site_module.view)
class TestERP5WebCategoryPublicationWorkflow(ERP5TypeTestCase): class TestERP5WebCategoryPublicationWorkflow(ERP5TypeTestCase):
......
...@@ -344,7 +344,7 @@ class TestTradeModelLine(TestTradeModelLineMixin): ...@@ -344,7 +344,7 @@ class TestTradeModelLine(TestTradeModelLineMixin):
packing_list.stop() packing_list.stop()
transaction.commit() transaction.commit()
self.tic() self.tic()
self.stepInvoiceBuilderAlarm() self.buildInvoices()
transaction.commit() transaction.commit()
self.tic() self.tic()
...@@ -478,21 +478,15 @@ class TestTradeModelLine(TestTradeModelLineMixin): ...@@ -478,21 +478,15 @@ class TestTradeModelLine(TestTradeModelLineMixin):
self.assertEquals(str(abs(line_dict['income_expense'])), self.assertEquals(str(abs(line_dict['income_expense'])),
str(rounded_total_price + rounded_discount_price)) str(rounded_total_price + rounded_discount_price))
def stepPackingListBuilderAlarm(self, sequence=None, def buildPackingLists(self):
sequence_list=None, **kw): self.portal.portal_alarms.packing_list_builder_alarm.activeSense()
# global builder alarm does not exist in legacy simulation transaction.commit()
# business templates. self.tic()
alarm = getattr(self.portal.portal_alarms, 'packing_list_builder_alarm', None)
if alarm is not None: def buildInvoices(self):
alarm.activeSense() self.portal.portal_alarms.invoice_builder_alarm.activeSense()
transaction.commit()
def stepInvoiceBuilderAlarm(self, sequence=None, self.tic()
sequence_list=None, **kw):
# global builder alarm does not exist in legacy simulation
# business templates.
alarm = getattr(self.portal.portal_alarms, 'invoice_builder_alarm', None)
if alarm is not None:
alarm.activeSense()
### ###
## Test cases ## Test cases
...@@ -606,9 +600,7 @@ class TestTradeModelLine(TestTradeModelLineMixin): ...@@ -606,9 +600,7 @@ class TestTradeModelLine(TestTradeModelLineMixin):
order.confirm() order.confirm()
transaction.commit() transaction.commit()
self.tic() self.tic()
self.stepPackingListBuilderAlarm() self.buildPackingLists()
transaction.commit()
self.tic()
packing_list, = order.getCausalityRelatedValueList( packing_list, = order.getCausalityRelatedValueList(
portal_type=self.packing_list_portal_type) portal_type=self.packing_list_portal_type)
...@@ -937,9 +929,7 @@ return lambda *args, **kw: 1""") ...@@ -937,9 +929,7 @@ return lambda *args, **kw: 1""")
order.confirm() order.confirm()
transaction.commit() transaction.commit()
self.tic() self.tic()
self.stepPackingListBuilderAlarm() self.buildPackingLists()
transaction.commit()
self.tic()
packing_list = order.getCausalityRelatedValue( packing_list = order.getCausalityRelatedValue(
portal_type=self.packing_list_portal_type) portal_type=self.packing_list_portal_type)
...@@ -951,9 +941,7 @@ return lambda *args, **kw: 1""") ...@@ -951,9 +941,7 @@ return lambda *args, **kw: 1""")
packing_list.deliver() packing_list.deliver()
transaction.commit() transaction.commit()
self.tic() self.tic()
self.stepInvoiceBuilderAlarm() self.buildInvoices()
transaction.commit()
self.tic()
invoice = packing_list.getCausalityRelatedValue( invoice = packing_list.getCausalityRelatedValue(
portal_type=self.invoice_portal_type) portal_type=self.invoice_portal_type)
......
...@@ -70,6 +70,8 @@ class TradeModelRule(Rule): ...@@ -70,6 +70,8 @@ class TradeModelRule(Rule):
context_movement = applied_rule.getParentValue() context_movement = applied_rule.getParentValue()
for amount in trade_condition.getAggregatedAmountList(context_movement): for amount in trade_condition.getAggregatedAmountList(context_movement):
if not amount.getQuantity():
continue
# business path specific # business path specific
business_path_list = business_process.getPathValueList( business_path_list = business_process.getPathValueList(
trade_phase=amount.getTradePhaseList(), context=context_movement) trade_phase=amount.getTradePhaseList(), context=context_movement)
......
...@@ -121,13 +121,10 @@ class TestSimulationPerformance(ERP5TypeTestCase, LogInterceptor): ...@@ -121,13 +121,10 @@ class TestSimulationPerformance(ERP5TypeTestCase, LogInterceptor):
""" """
Return the list of business templates. Return the list of business templates.
""" """
return ('erp5_base', return ('erp5_core_proxy_field_legacy', 'erp5_base',
'erp5_pdm', 'erp5_pdm', 'erp5_simulation', 'erp5_trade',
'erp5_trade', 'erp5_accounting', 'erp5_invoicing', 'erp5_advanced_invoicing',
'erp5_invoicing', 'erp5_simulation_test', 'erp5_simulation_performance_test')
'erp5_accounting',
'erp5_advanced_invoicing',
'erp5_simulation_performance_test',)
def afterSetUp(self): def afterSetUp(self):
""" """
...@@ -794,6 +791,9 @@ class TestSimulationPerformance(ERP5TypeTestCase, LogInterceptor): ...@@ -794,6 +791,9 @@ class TestSimulationPerformance(ERP5TypeTestCase, LogInterceptor):
number_of_additional_sale_packing_list_lines=5, number_of_additional_sale_packing_list_lines=5,
measurable=True) measurable=True)
from Products.ERP5Legacy.tests import Legacy_getBusinessTemplateList
Legacy_getBusinessTemplateList(TestSimulationPerformance)
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestSimulationPerformance)) suite.addTest(unittest.makeSuite(TestSimulationPerformance))
......
...@@ -52,6 +52,9 @@ for name in list(TestTradeModelLine.__dict__): ...@@ -52,6 +52,9 @@ for name in list(TestTradeModelLine.__dict__):
if '_NewSimulation_' in name: if '_NewSimulation_' in name:
delattr(TestTradeModelLine, name) delattr(TestTradeModelLine, name)
TestTradeModelLine.buildInvoices = TestTradeModelLine.buildPackingLists = \
lambda self: None
def createBusinessProcess(self, *args, **kw): def createBusinessProcess(self, *args, **kw):
business_process = super(TestTradeModelLine, self) \ business_process = super(TestTradeModelLine, self) \
.createBusinessProcess(*args, **kw) .createBusinessProcess(*args, **kw)
......
...@@ -57,7 +57,7 @@ class ERP5(_ERP5): ...@@ -57,7 +57,7 @@ class ERP5(_ERP5):
# skip some tests # skip some tests
if test_case.startswith('testLive') or test_case.startswith('testVifib') \ if test_case.startswith('testLive') or test_case.startswith('testVifib') \
or test_case.startswith('testFunctional') \ or test_case.startswith('testFunctional') \
or test_case in ('testPerformance', 'testSimulationPerformance', or test_case in ('testPerformance', 'testLegacySimulationPerformance',
'testERP5LdapCatalog', # XXX (Ivan), until LDAP server is available this test will alway fail 'testERP5LdapCatalog', # XXX (Ivan), until LDAP server is available this test will alway fail
'testERP5eGov', # it is not maintained any more 'testERP5eGov', # it is not maintained any more
'testAccounting_l10n_fr_m9'): 'testAccounting_l10n_fr_m9'):
......
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