diff --git a/bt5/erp5_accounting_l10n_fr/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr/AccountingTransactionModule_aggregateFrenchAccountingTransactionFile.py b/bt5/erp5_accounting_l10n_fr/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr/AccountingTransactionModule_aggregateFrenchAccountingTransactionFile.py index 2e941cb03af9accfeb05dc8f3185e2582471ed56..ea83802e5342a08dd8c8966dd5dd4c206879c1c4 100644 --- a/bt5/erp5_accounting_l10n_fr/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr/AccountingTransactionModule_aggregateFrenchAccountingTransactionFile.py +++ b/bt5/erp5_accounting_l10n_fr/SkinTemplateItem/portal_skins/erp5_accounting_l10n_fr/AccountingTransactionModule_aggregateFrenchAccountingTransactionFile.py @@ -1,6 +1,7 @@ # coding: utf-8 import unicodedata -from six.moves import cStringIO as StringIO +import six +from io import BytesIO import zipfile from Products.ERP5Type.Message import translateString @@ -22,7 +23,7 @@ if test_compta_demat_compatibility: 'NFKD', fec_file.replace(u"鈧�", "EUR") ).encode('ascii', 'ignore') -zipbuffer = StringIO() +zipbuffer = BytesIO() zipfilename = at_date.strftime('FEC-%Y%m%d.zip') zipfileobj = zipfile.ZipFile(zipbuffer, 'w', compression=zipfile.ZIP_DEFLATED) filename = 'FEC.xml' @@ -42,9 +43,15 @@ attachment_list = ( 'content': zipbuffer.getvalue(), 'name': zipfilename, }, ) +subject = translateString('French Accounting Transaction File') +if six.PY2: + subject = unicode(subject) +else: + subject = str(subject) + portal.ERP5Site_notifyReportComplete( user_name=user_name, - subject=unicode(translateString('French Accounting Transaction File')), + subject=subject, message='', attachment_list=attachment_list) diff --git a/bt5/erp5_base/DocumentTemplateItem/portal_components/document.erp5.Url.py b/bt5/erp5_base/DocumentTemplateItem/portal_components/document.erp5.Url.py index 05a1a965abc49e803f9d124c01b7ca318b05da0c..d59ced6011d3425ea8d9eb13144c29e3b49542ef 100644 --- a/bt5/erp5_base/DocumentTemplateItem/portal_components/document.erp5.Url.py +++ b/bt5/erp5_base/DocumentTemplateItem/portal_components/document.erp5.Url.py @@ -121,9 +121,9 @@ class Url(Coordinate, UrlMixin): This method was previously named 'SendMail' and is used to send email * attachment_list is a list of dictionnaries with those keys: - - name : name of the attachment, - - content: data of the attachment - - mime_type: mime-type corresponding to the attachment + - name (str): name of the attachment, + - content (bytes): data of the attachment + - mime_type (str): mime-type corresponding to the attachment * extra_headers is a dictionnary of custom headers to add to the email. "X-" prefix is automatically added to those headers. """ diff --git a/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_createMailMessageAsString.py b/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_createMailMessageAsString.py index 6d36645a36fe6ca40dfd29353507ca3ab92c134e..8144e6f5f676e6739292147935217d0d23015614 100644 --- a/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_createMailMessageAsString.py +++ b/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Base_createMailMessageAsString.py @@ -6,10 +6,10 @@ * body: body of the message as UTF-8 encoded string * content_type: mime type of this message, can be text/html for HTML message or anything else for text/plain message. - * attachment_list: a list of attachement mapping in format: - - mime_type: mime type of thsi attachement - - content: file content of the attachement, as a string - - name: displayed name of this attachements + * attachment_list: a list of attachment mapping in format: + - mime_type (str): mime type of thsi attachment + - content (bytes): file content of the attachment + - name (str): displayed name of this attachment * embedded_file_list: a list of ERP5 File to use as attachments. * extra_header_dict: additional email headers diff --git a/bt5/erp5_deferred_style/SkinTemplateItem/portal_skins/erp5_deferred_style_core/Base_renderSimpleView.py b/bt5/erp5_deferred_style/SkinTemplateItem/portal_skins/erp5_deferred_style_core/Base_renderSimpleView.py index 49307c434d3593febab4963466001045dd48981d..506b68adae1a912d6090d49f2714f6c5716b7f26 100644 --- a/bt5/erp5_deferred_style/SkinTemplateItem/portal_skins/erp5_deferred_style_core/Base_renderSimpleView.py +++ b/bt5/erp5_deferred_style/SkinTemplateItem/portal_skins/erp5_deferred_style_core/Base_renderSimpleView.py @@ -30,7 +30,7 @@ with portal.Localizer.translationContext(localizer_language): attachment_name = attachment_name[:-1] attachment_list = ( {'mime_type': (request.RESPONSE.getHeader('content-type') or 'application/octet-stream;').split(';')[0], - 'content': '%s' % report_data, + 'content': bytes(report_data), 'name': attachment_name},) getattr(portal, notify_report_complete_script_id)( diff --git a/bt5/erp5_deferred_style/SkinTemplateItem/portal_skins/erp5_deferred_style_core/Base_report.py b/bt5/erp5_deferred_style/SkinTemplateItem/portal_skins/erp5_deferred_style_core/Base_report.py index 6792aa069d7277042e6675604deeefdb10bf62b8..c9d200b3a3308c46ebbf437557b334c837be87f8 100644 --- a/bt5/erp5_deferred_style/SkinTemplateItem/portal_skins/erp5_deferred_style_core/Base_report.py +++ b/bt5/erp5_deferred_style/SkinTemplateItem/portal_skins/erp5_deferred_style_core/Base_report.py @@ -51,7 +51,7 @@ with portal.Localizer.translationContext(localizer_language): attachment_list = ( {'mime_type': (request.RESPONSE.getHeader('content-type') or 'application/octet-stream;').split(';')[0], - 'content': '%s' % report_data, + 'content': bytes(report_data), 'name': attachment_name},) getattr(portal, notify_report_complete_script_id)( diff --git a/product/ERP5/Document/Alarm.py b/product/ERP5/Document/Alarm.py index 9e25d96df8026db56d83fbb13b18fa1cc6155621..ecc21d31b97a62263b241964efa20ce5e91c64ec 100644 --- a/product/ERP5/Document/Alarm.py +++ b/product/ERP5/Document/Alarm.py @@ -355,7 +355,7 @@ class Alarm(XMLObject, PeriodicityMixin): for x in result_list] rendered_alarm_result = '\n'.join(rendered_alarm_result_list) attachment_list.append({'name': 'alarm_result.txt', - 'content': rendered_alarm_result, + 'content': rendered_alarm_result.encode(), 'mime_type': 'text/plain'}) notification_tool.sendMessage(recipient=candidate_list, diff --git a/product/ERP5/bootstrap/erp5_core/ToolComponentTemplateItem/portal_components/tool.erp5.NotificationTool.py b/product/ERP5/bootstrap/erp5_core/ToolComponentTemplateItem/portal_components/tool.erp5.NotificationTool.py index 0769ddca5ff1a2bc1916ff185f578fbf8fcc3a58..4d32679940a010b92ccee19e49ee18707280f209 100644 --- a/product/ERP5/bootstrap/erp5_core/ToolComponentTemplateItem/portal_components/tool.erp5.NotificationTool.py +++ b/product/ERP5/bootstrap/erp5_core/ToolComponentTemplateItem/portal_components/tool.erp5.NotificationTool.py @@ -109,9 +109,9 @@ def buildEmailMessage(from_url, to_url, msg=None, sent by Zope MailHost. * attachment_list is a list of dictionaries with those keys: - - name : name of the attachment, - - content: data of the attachment - - mime_type: mime-type corresponding to the attachment + - name (str): name of the attachment + - content (bytes): data of the attachment + - mime_type (str): mime-type corresponding to the attachment * extra_headers is a dictionary of custom headers to add to the email. "X-" prefix is automatically added to those headers. * additional_headers is similar to extra_headers, but no prefix is added.