diff --git a/todo_list/__init__.py b/todo_list/__init__.py index f2c5a4636..05272df38 100644 --- a/todo_list/__init__.py +++ b/todo_list/__init__.py @@ -3,7 +3,7 @@ # # Cybrosys Technologies Pvt. Ltd. # -# Copyright (C) 2021-TODAY Cybrosys Technologies() +# Copyright (C) 2024-TODAY Cybrosys Technologies() # Author: Cybrosys Techno Solutions() # # You can modify it under the terms of the GNU LESSER diff --git a/todo_list/__manifest__.py b/todo_list/__manifest__.py index 63fae9fdf..48fc406e9 100644 --- a/todo_list/__manifest__.py +++ b/todo_list/__manifest__.py @@ -3,7 +3,7 @@ # # Cybrosys Technologies Pvt. Ltd. # -# Copyright (C) 2021-TODAY Cybrosys Technologies() +# Copyright (C) 2024-TODAY Cybrosys Technologies() # Author: Cybrosys Techno Solutions() # # You can modify it under the terms of the GNU LESSER @@ -21,6 +21,8 @@ ############################################################################# { 'name': "To Do List", + 'version': '16.0.2.0.1', + 'category': 'Tools', 'summary': """ Create Todo List Using Activities""", 'description': """ @@ -31,9 +33,7 @@ 'maintainer': 'Cybrosys Techno Solutions', 'website': "https://www.cybrosys.com", 'live_test_url': 'https://youtu.be/LGiDWPFdkbks', - 'category': 'Tools', - 'version': '16.0.2.0.0', - 'depends': ['base','sale','mail'], + 'depends': ['base', 'sale', 'mail'], 'data': [ 'security/security.xml', 'security/ir.model.access.csv', @@ -41,8 +41,8 @@ 'data/general.xml', 'views/views.xml', ], - 'license': 'LGPL-3', 'images': ['static/description/banner.png'], + 'license': 'LGPL-3', 'installable': True, 'auto_install': False, 'application': True, diff --git a/todo_list/doc/RELEASE_NOTES.md b/todo_list/doc/RELEASE_NOTES.md index a65fdece4..3a014b0a3 100644 --- a/todo_list/doc/RELEASE_NOTES.md +++ b/todo_list/doc/RELEASE_NOTES.md @@ -6,4 +6,12 @@ - Initial Commit for todo_list +#### 31.07.2024 +#### Version 16.0.1.0.1 +##### ADD + +- Added monkey patch for todo_list + + + diff --git a/todo_list/models/__init__.py b/todo_list/models/__init__.py index 0c4eccefd..b8541c19d 100644 --- a/todo_list/models/__init__.py +++ b/todo_list/models/__init__.py @@ -3,7 +3,7 @@ # # Cybrosys Technologies Pvt. Ltd. # -# Copyright (C) 2021-TODAY Cybrosys Technologies() +# Copyright (C) 2024-TODAY Cybrosys Technologies() # Author: Cybrosys Techno Solutions() # # You can modify it under the terms of the GNU LESSER @@ -21,3 +21,4 @@ ############################################################################# from . import todo +from . import res_users diff --git a/todo_list/models/res_users.py b/todo_list/models/res_users.py new file mode 100644 index 000000000..ce8c79675 --- /dev/null +++ b/todo_list/models/res_users.py @@ -0,0 +1,82 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions() +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +from collections import defaultdict + +from odoo import api, modules, _ +from odoo.addons.mail.models.res_users import Users + + +@api.model +def systray_get_activities(self): + """ + Overridden, to also consider the newly added states in mail activity. + """ + activities = self.env["mail.activity"].search( + [("user_id", "=", self.env.uid)]) + activities_by_record_by_model_name = defaultdict( + lambda: defaultdict(lambda: self.env["mail.activity"])) + for activity in activities: + record = self.env[activity.res_model].browse(activity.res_id) + activities_by_record_by_model_name[activity.res_model][ + record] += activity + model_ids = list({self.env["ir.model"]._get(name).id for name in + activities_by_record_by_model_name.keys()}) + user_activities = {} + for model_name, activities_by_record in activities_by_record_by_model_name.items(): + domain = [ + ("id", "in", list({r.id for r in activities_by_record.keys()}))] + allowed_records = self.env[model_name].search(domain) + if not allowed_records: + continue + module = self.env[model_name]._original_module + icon = module and modules.module.get_module_icon(module) + model = self.env["ir.model"]._get(model_name).with_prefetch(model_ids) + user_activities[model_name] = { + "id": model.id, + "name": model.name, + "model": model_name, + "type": "activity", + "icon": icon, + "total_count": 0, + "today_count": 0, + "overdue_count": 0, + "planned_count": 0, + "done_count": 0, + "cancel_count": 0, + "actions": [ + { + "icon": "fa-clock-o", + "name": "Summary", + } + ], + } + for record, activities in activities_by_record.items(): + if record not in allowed_records: + continue + for activity in activities: + user_activities[model_name]["%s_count" % activity.state] += 1 + if activity.state in ("today", "overdue"): + user_activities[model_name]["total_count"] += 1 + return list(user_activities.values()) + + +Users.systray_get_activities = systray_get_activities diff --git a/todo_list/models/todo.py b/todo_list/models/todo.py index 5258258a3..fe0fe7c05 100644 --- a/todo_list/models/todo.py +++ b/todo_list/models/todo.py @@ -3,7 +3,7 @@ # # Cybrosys Technologies Pvt. Ltd. # -# Copyright (C) 2021-TODAY Cybrosys Technologies() +# Copyright (C) 2024-TODAY Cybrosys Technologies() # Author: Cybrosys Techno Solutions() # # You can modify it under the terms of the GNU LESSER @@ -42,7 +42,8 @@ class MailActivity(models.Model): res_id = fields.Many2oneReference(string='Related Document ID', index=True, required=True, model_field='res_model', default=lambda self: self.env.ref( - 'todo_list.general_activities',False)) + 'todo_list.general_activities', + False)) priority = fields.Selection([ ('0', 'Normal'), ('1', 'Important'),