From 52b49425250fa8cfa530818a226bb610de0d6f18 Mon Sep 17 00:00:00 2001 From: Parth Choksi Date: Tue, 18 Dec 2018 08:48:29 +0000 Subject: [PATCH] [IMP] digest: improve the digest email layout Purpose of the task is to improve the usability of digest email layout. - Click on Connect button to connect to the database. - Use same left padding in the header as in the section title. - 2 decimal digits for monetary amounts, no space with currency symbol. - Count real messages only, not notes or notifications. - Add new tips for video tour. - Moved recipients to a new tab. - Changed email author to company's email. - Some minor layout fixes. Task-1918364 --- addons/digest/data/digest_data.xml | 13 +++++++++++- addons/digest/data/digest_template_data.xml | 23 ++++++++++++--------- addons/digest/models/digest.py | 16 +++++++------- addons/digest/views/digest_views.xml | 11 +++++++++- addons/sale_expense/data/digest_data.xml | 4 ++-- 5 files changed, 44 insertions(+), 23 deletions(-) diff --git a/addons/digest/data/digest_data.xml b/addons/digest/data/digest_data.xml index 76c6e373d80..5c7c2c792ba 100644 --- a/addons/digest/data/digest_data.xml +++ b/addons/digest/data/digest_data.xml @@ -2,7 +2,7 @@ - Weekly Digest + Weekly Stats in Odoo True @@ -41,5 +41,16 @@ + + + + 0 + +
+ To reach your full potential with Odoo, have a look at our apps videos and discover new tools to work better and faster. +
+
+
+
diff --git a/addons/digest/data/digest_template_data.xml b/addons/digest/data/digest_template_data.xml index aeaa6a54253..72826734049 100644 --- a/addons/digest/data/digest_template_data.xml +++ b/addons/digest/data/digest_template_data.xml @@ -3,8 +3,8 @@ Digest: Default main template - ${user.email_formatted | safe} ${'%s: %s' % (ctx.get('user', user).company_id.name, object.name)} + ${('%s' % (object.company_id.partner_id.email_formatted or user.email_formatted))|safe} @@ -17,12 +17,15 @@ % set kpis = data.yesterday.keys()
- -
- ${company.name} at a glance -
${datetime.date.today().strftime('%B %d, %Y')}
+
+ ${object.name} +
${datetime.date.today().strftime('%B %d, %Y')}
+ +
+ Connect +
@@ -85,10 +88,10 @@
- + -
+ ${data['lastmonth'][kpi][kpi]}
Last 30 Days % if data['lastmonth'][kpi]['margin'] != 0.0: @@ -114,7 +117,7 @@ % if tips: - @@ -127,7 +130,7 @@ - @@ -138,7 +141,7 @@

+

${tips | safe}
+
% if user.has_group('base.group_system'):
- Want to customize the email? + Want to customize this email? Choose the metrics you care about

diff --git a/addons/digest/models/digest.py b/addons/digest/models/digest.py index eb4fd1190bb..1d10c59d504 100644 --- a/addons/digest/models/digest.py +++ b/addons/digest/models/digest.py @@ -65,9 +65,10 @@ class Digest(models.Model): record.kpi_res_users_connected_value = user_connected def _compute_kpi_mail_message_total_value(self): + discussion_subtype_id = self.env.ref('mail.mt_comment').id for record in self: start, end, company = record._get_kpi_compute_parameters() - total_messages = self.env['mail.message'].search_count([('create_date', '>=',start), ('create_date', '<', end)]) + total_messages = self.env['mail.message'].search_count([('create_date', '>=', start), ('create_date', '<', end), ('subtype_id', '=', discussion_subtype_id), ('message_type', 'in', ['comment', 'email'])]) record.kpi_mail_message_total_value = total_messages @api.onchange('periodicity') @@ -181,19 +182,16 @@ class Digest(models.Model): return margin def _format_currency_amount(self, amount, currency_id): - pre = post = u'' - if currency_id.position == 'before': - pre = u'{symbol}\N{NO-BREAK SPACE}'.format(symbol=currency_id.symbol or '') - else: - post = u'\N{NO-BREAK SPACE}{symbol}'.format(symbol=currency_id.symbol or '') - return u'{pre}{0}{post}'.format(amount, pre=pre, post=post) + 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.1f%s%s" % (amount, unit, suffix) + return "%3.2f%s%s" % (amount, unit, suffix) amount /= 1000.0 - return "%.1f%s%s" % (amount, 'T', suffix) + return "%.2f%s%s" % (amount, 'T', suffix) @api.model def _cron_send_digest_email(self): diff --git a/addons/digest/views/digest_views.xml b/addons/digest/views/digest_views.xml index dc348837227..44bdfd355e7 100644 --- a/addons/digest/views/digest_views.xml +++ b/addons/digest/views/digest_views.xml @@ -45,7 +45,6 @@ - @@ -62,6 +61,16 @@ + + + + + + + + + +