diff options
| author | Dharmang Soni <dpr@openerp.com> | 2018-04-04 15:34:43 +0530 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2018-04-09 14:35:06 +0200 |
| commit | 807c4c3f5e729d8b2f463d93e73b0dbbc008492b (patch) | |
| tree | dc6774487c50efbd6c09b5ae642744582b3fe260 /addons/note/models | |
| parent | c56491b11bc399247a595a2e08bbc940d2be3746 (diff) | |
[REF] mail, note: move reminder feature from mail to note
This commit refactors f488dc58c37fdc7fd49df759165de641e213444b that added reminder feature in activities.
After merging it was suggested specifications were not correct and it has
been decided to move the whole reminder feature in note.
Reminders are now notes instead of activities. Now when having note appµ
systray proposes to create a note / reminder. A note.note record is created
with info given by the user. If a date is given in the systray quick create
then an activity is scheduled on this note.
This means user can create records in activity systray that are not
activities but notes used as reminders. Those will use the first availableµ
note column for the user.
As reminders are now notes the support of activities not linked to any
document is removed, as well as archiving activities and tests linked to
that behavior.
This commit has been not carefully tested nor in-depth reviewied. It is
considered as too important for the upcoming freeze. This closes task ID
1833628. Closes #24129 . Many thanks to @dpr-odoo for its quick development
and good work on this task.
Diffstat (limited to 'addons/note/models')
| -rw-r--r-- | addons/note/models/__init__.py | 1 | ||||
| -rw-r--r-- | addons/note/models/mail_activity.py | 16 | ||||
| -rw-r--r-- | addons/note/models/res_users.py | 27 |
3 files changed, 43 insertions, 1 deletions
diff --git a/addons/note/models/__init__.py b/addons/note/models/__init__.py index 5c651fca9a0..db6de6e3c7f 100644 --- a/addons/note/models/__init__.py +++ b/addons/note/models/__init__.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. +from . import mail_activity from . import note from . import res_users diff --git a/addons/note/models/mail_activity.py b/addons/note/models/mail_activity.py new file mode 100644 index 00000000000..67f7ea82966 --- /dev/null +++ b/addons/note/models/mail_activity.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import models, fields + + +class MailActivityType(models.Model): + _inherit = "mail.activity.type" + + category = fields.Selection(selection_add=[('reminder', 'Reminder')]) + + +class MailActivity(models.Model): + _inherit = "mail.activity" + + note_id = fields.Many2one('note.note', string="Related Note", ondelete='cascade') 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 |
