From 208af7f5fc98fcc706532970bde88ca47d157fae Mon Sep 17 00:00:00 2001
From: wan <wan@odoo.com>
Date: Tue, 8 Oct 2019 12:43:06 +0000
Subject: [PATCH] [IMP] account: add the period of the tax periodicity on the
 dashboard

Task 2076244
Commit 4a1bbbf added that but it had to be reverted because it didn't
take into account the periodicity of the tax return of the company and
because it added the period for all mail.activity

closes odoo/odoo#38199

Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
---
 addons/account/models/account_journal_dashboard.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/addons/account/models/account_journal_dashboard.py b/addons/account/models/account_journal_dashboard.py
index 8ec85efb285d..975c88cdf168 100644
--- a/addons/account/models/account_journal_dashboard.py
+++ b/addons/account/models/account_journal_dashboard.py
@@ -50,7 +50,7 @@ class account_journal(models.Model):
             '''
             self.env.cr.execute(sql_query, (journal.id,))
             for activity in self.env.cr.dictfetchall():
-                activities.append({
+                act = {
                     'id': activity.get('id'),
                     'res_id': activity.get('res_id'),
                     'res_model': activity.get('res_model'),
@@ -58,7 +58,13 @@ class account_journal(models.Model):
                     'name': (activity.get('summary') or activity.get('act_type_name')),
                     'activity_category': activity.get('activity_category'),
                     'date': odoo_format_date(self.env, activity.get('date_deadline'))
-                })
+                }
+                if activity.get('activity_category') == 'tax_report' and activity.get('res_model') == 'account.move':
+                    if self.env['account.move'].browse(activity.get('res_id')).company_id.account_tax_periodicity == 'monthly':
+                        act['name'] += ' (' + format_date(activity.get('date'), 'MMM', locale=get_lang(self.env).code) + ')'
+                    else:
+                        act['name'] += ' (' + format_date(activity.get('date'), 'QQQ', locale=get_lang(self.env).code) + ')'
+                activities.append(act)
             journal.json_activity_data = json.dumps({'activities': activities})
 
     kanban_dashboard = fields.Text(compute='_kanban_dashboard')
-- 
GitLab