diff options
| author | std-odoo <std@odoo.com> | 2020-04-17 07:37:45 +0000 |
|---|---|---|
| committer | Debauche Stéphane <std@odoo.com> | 2020-06-12 11:49:45 +0000 |
| commit | b16843230d9c62606550c061934f319fee23d3c5 (patch) | |
| tree | 2b7608860889186fffa902ae2cf9cbb466d4281f /addons/digest/models | |
| parent | 5227f956da1b64293f3e1301ff03b4efb28db80b (diff) | |
[IMP] mass_mailing: send a statistics email to the mailing responsible
Purpose
=======
Provide a follow-up/overview of the Mailing 24 hours after its been sent.
Specifications
==============
Send an email to the responsible of the mailing 24 hours the last email
of the mass mailing.
During the link trackers creation, extract the button label if exists
(so we can display them in the statistics email).
Technical remarks
=================
The statistics email is sent to the responsible of each mailing in the
CRON of mass mailing.
Task-2227411
closes odoo/odoo#49836
Related: odoo/upgrade#1094
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Diffstat (limited to 'addons/digest/models')
| -rw-r--r-- | addons/digest/models/digest.py | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/addons/digest/models/digest.py b/addons/digest/models/digest.py index c6e51a4fb9a..b9ff6bf0829 100644 --- a/addons/digest/models/digest.py +++ b/addons/digest/models/digest.py @@ -6,6 +6,7 @@ import pytz from datetime import datetime, date from dateutil.relativedelta import relativedelta +from werkzeug.urls import url_join from odoo import api, fields, models, tools, _ from odoo.addons.base.models.ir_mail_server import MailDeliveryException @@ -112,16 +113,21 @@ class Digest(models.Model): digest.next_run_date = digest._get_next_run_date() def _action_send_to_user(self, user, tips_count=1): + web_base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url') + rendered_body = self.env['mail.render.mixin']._render_template( 'digest.digest_mail_main', 'digest.digest', self.ids, engine='qweb', add_context={ + 'title': self.name, + 'top_button_label': _('Connect'), + 'top_button_url': url_join(web_base_url, '/web/login'), 'company': user.company_id, 'user': user, 'tips_count': tips_count, - 'datetime': datetime, # TDE TEMP FIXME + 'formatted_date': datetime.today().strftime('%B %d, %Y'), 'display_mobile_banner': True, 'kpi_data': self.compute_kpis(user.company_id, user), 'tips': self.compute_tips(user.company_id, user, tips_count=tips_count), @@ -211,7 +217,7 @@ class Digest(models.Model): continue margin = self._get_margin_value(compute_value, previous_value) if self._fields['%s_value' % field_name].type == 'monetary': - converted_amount = self._format_human_readable_amount(compute_value) + converted_amount = tools.format_decimalized_amount(compute_value) compute_value = self._format_currency_amount(converted_amount, company.currency_id) kpi_values['kpi_col%s' % (col_index + 1)].update({ 'value': compute_value, @@ -328,10 +334,3 @@ class Digest(models.Model): pre = currency_id.position == 'before' symbol = u'{symbol}'.format(symbol=currency_id.symbol or '') return u'{pre}{0}{post}'.format(amount, pre=symbol if pre else '', post=symbol if not pre else '') - - def _format_human_readable_amount(self, amount, suffix=''): - for unit in ['', 'K', 'M', 'G']: - if abs(amount) < 1000.0: - return "%3.2f%s%s" % (amount, unit, suffix) - amount /= 1000.0 - return "%.2f%s%s" % (amount, 'T', suffix) |
