summaryrefslogtreecommitdiff
path: root/addons/note/models/res_users.py
diff options
context:
space:
mode:
Diffstat (limited to 'addons/note/models/res_users.py')
-rw-r--r--addons/note/models/res_users.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/addons/note/models/res_users.py b/addons/note/models/res_users.py
index cfeba15922f..be218c27b28 100644
--- a/addons/note/models/res_users.py
+++ b/addons/note/models/res_users.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
-from odoo import api, models
+from odoo import api, models, modules, _
class Users(models.Model):
@@ -19,3 +19,28 @@ class Users(models.Model):
if stage:
stage.sudo().copy(default={'user_id': user.id})
return user
+
+ @api.model
+ def activity_user_count(self):
+ """ If user have not scheduled any note, it will not appear in activity menu.
+ Making note activity always visible with number of notes on label. If there is no notes,
+ activity menu not visible for note.
+ """
+ activities = super(Users, self).activity_user_count()
+ notes_count = self.env['note.note'].search_count([('user_id', '=', self.env.uid), ('open', '=', True)])
+ if notes_count:
+ note_index = next((index for (index, a) in enumerate(activities) if a["model"] == "note.note"), None)
+ note_label = ("%s (%d)") % (_('Notes'), notes_count)
+ if note_index is not None:
+ activities[note_index]['name'] = note_label
+ else:
+ activities.append({
+ 'name': note_label,
+ 'model': 'note.note',
+ 'icon': modules.module.get_module_icon(self.env['note.note']._original_module),
+ 'total_count': 0,
+ 'today_count': 0,
+ 'overdue_count': 0,
+ 'planned_count': 0
+ })
+ return activities