Commit 180a1777 authored by Romain Courteaud's avatar Romain Courteaud

slapos_crm: no need to manually handle the notification message

parent 510fd11d
...@@ -23,6 +23,7 @@ ticket = portal.portal_catalog.getResultValue( ...@@ -23,6 +23,7 @@ ticket = portal.portal_catalog.getResultValue(
if ticket is not None: if ticket is not None:
return ticket, None return ticket, None
mail_message = None
outstanding_amount = person.Entity_statSlapOSOutstandingAmount() outstanding_amount = person.Entity_statSlapOSOutstandingAmount()
# It can't be smaller, we are considernig all open invoices are from unpaid_payment_amount # It can't be smaller, we are considernig all open invoices are from unpaid_payment_amount
...@@ -55,43 +56,26 @@ if int(outstanding_amount) > 0: ...@@ -55,43 +56,26 @@ if int(outstanding_amount) > 0:
ticket.reindexObject(activate_kw={'tag': tag}) ticket.reindexObject(activate_kw={'tag': tag})
# Notify using user's language subject = 'Invoice payment requested'
language = context.getLanguage("en") body = """Dear %s,
notification_message = context.getPortalObject().portal_notifications.getDocumentValue( A new invoice has been generated.
reference="slapos-crm.create.regularisation.request",
language=language)
if notification_message is None:
subject = 'Invoice payment requested'
body = """Dear %s,
A new invoice has been generated.
You can access it in your invoice section at %s. You can access it in your invoice section at %s.
Regards, Regards,
The slapos team The slapos team
""" % (context.getTitle(), portal.portal_preferences.getPreferredSlaposWebSiteUrl()) """ % (context.getTitle(), portal.portal_preferences.getPreferredSlaposWebSiteUrl())
notification_message_reference = "slapos-crm.create.regularisation.request"
else:
notification_mapping_dict = {
'user_name': context.getTitle()}
subject = notification_message.getTitle()
# Preserve HTML else convert to text
if notification_message.getContentType() == "text/html":
body = notification_message.asEntireHTML(
substitution_method_parameter_dict={'mapping_dict':notification_mapping_dict})
else:
body = notification_message.asText(
substitution_method_parameter_dict={'mapping_dict':notification_mapping_dict})
mail_message = ticket.RegularisationRequest_checkToSendUniqEvent( mail_message = ticket.RegularisationRequest_checkToSendUniqEvent(
portal.portal_preferences.getPreferredRegularisationRequestResource(), portal.portal_preferences.getPreferredRegularisationRequestResource(),
subject, subject,
body, body,
'Requested manual payment.') 'Requested manual payment.',
notification_message=notification_message_reference,
return ticket, mail_message substitution_method_parameter_dict={
'user_name': context.getTitle()
},
)
return ticket, None return ticket, mail_message
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