From a6ee929bb1a3ab01552ac90e21f72d41e344b36c Mon Sep 17 00:00:00 2001 From: Parth Choksi Date: Mon, 6 May 2019 12:10:26 +0000 Subject: [PATCH 1/5] [FIX] digest: tips will be displayed properly Currenly in the digest when you send the template, tips are not being seen. The reason for this is, we are getting tips from the context but we dont have it in the context. Instead, we are fetching the tips by calling the compute_tips method and assigning it to 'tips'. Hence, this commit will remove the usage of context to get the tips as we are getting it from the method and not from the context. Task ID: #1918364 --- addons/digest/data/digest_template_data.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/digest/data/digest_template_data.xml b/addons/digest/data/digest_template_data.xml index c333e76455c..aeaa6a54253 100644 --- a/addons/digest/data/digest_template_data.xml +++ b/addons/digest/data/digest_template_data.xml @@ -115,7 +115,7 @@

-
${ctx['tip_description']|safe}
+
${tips | safe}
From e554ce345fb1ffcf41c571f461b680e1e7199a1d Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Wed, 10 Apr 2019 17:45:04 +0000 Subject: [PATCH 2/5] [FIX] requirements: bump up jinja2 reqs Recommended by GitHub's repository alerts. We normally stick as close as possible to the version we depend on in the official DEB packages. This in turn depends on the version of Debian stable at the time of release - for 11.0 that would be Debian 9 (stretch) and thus Jinja 2.8 (with security backports). However Jinja2 before 2.10.1 suffers from a few issues that could lead to crashes of Odoo processes. It seems it's worth an exception to our rule for pip users, similarly to previous bump up at d2605bccdba1838db5700a6ae0dd12ca9f9b20c7. closes odoo/odoo#32601 Signed-off-by: Christophe Simonis --- requirements.txt | 3 +-- setup/win32/winpy_requirements.txt | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index 96cd5c7852b..927036d5e22 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,8 +9,7 @@ gevent==1.3.4 ; sys_platform != 'win32' and python_version >= '3.7' greenlet==0.4.10 ; python_version < '3.7' greenlet==0.4.13 ; python_version >= '3.7' html2text==2016.9.19 -Jinja2==2.8.1 -libsass==0.12.3 +Jinja2==2.10.1 lxml==3.7.1 ; sys_platform != 'win32' and python_version < '3.7' lxml==4.2.3 ; sys_platform != 'win32' and python_version >= '3.7' lxml ; sys_platform == 'win32' diff --git a/setup/win32/winpy_requirements.txt b/setup/win32/winpy_requirements.txt index c086ad3d823..41d3fd5adff 100644 --- a/setup/win32/winpy_requirements.txt +++ b/setup/win32/winpy_requirements.txt @@ -6,7 +6,7 @@ feedparser==5.2.1 gevent>=1.1.2 greenlet>=0.4.10 html2text==2016.9.19 -Jinja2==2.8 +Jinja2==2.10.1 lxml>=3.5.0 Mako==1.0.4 MarkupSafe==0.23 From 52b49425250fa8cfa530818a226bb610de0d6f18 Mon Sep 17 00:00:00 2001 From: Parth Choksi Date: Tue, 18 Dec 2018 08:48:29 +0000 Subject: [PATCH 3/5] [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 @@ + + + + + + + + + +