Commit b9b1396b authored by Xiaowu Zhang's avatar Xiaowu Zhang Committed by Titouan Soulard

erp5_deferred_style: send a notification if there has error when generate report

parent 7cbce653
...@@ -14,6 +14,7 @@ if skin_name and skin_name != 'None': # make_query serializes None as 'None' ...@@ -14,6 +14,7 @@ if skin_name and skin_name != 'None': # make_query serializes None as 'None'
portal.portal_skins.changeSkin(skin_name) portal.portal_skins.changeSkin(skin_name)
with portal.Localizer.translationContext(localizer_language): with portal.Localizer.translationContext(localizer_language):
try:
report_data = getattr(context, deferred_style_dialog_method)(**params) report_data = getattr(context, deferred_style_dialog_method)(**params)
attachment_name_list = [x[len(' filename='):] for x in (request.RESPONSE.getHeader( attachment_name_list = [x[len(' filename='):] for x in (request.RESPONSE.getHeader(
...@@ -41,3 +42,18 @@ with portal.Localizer.translationContext(localizer_language): ...@@ -41,3 +42,18 @@ with portal.Localizer.translationContext(localizer_language):
format=report_format, format=report_format,
**notify_report_complete_kwargs **notify_report_complete_kwargs
) )
except Exception, Error:
if type(report_data) is dict and report_data.pop('status', 0) == -2:
message = report_data.pop('message')
subject = report_data.pop('subject')
else:
message = 'Unknown Error, Please Retry'
subject = 'ERP5: Deferred Report'
getattr(portal, notify_report_complete_script_id)(
user_name=user_name,
subject=subject,
attachment_list = [],
message=message,
format=report_format
)
context.log(Error)
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