From 8be06de0af2fcd77c3cba37951cfe7a7b0d7320b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 5 Sep 2018 14:56:10 +0200 Subject: [PATCH 1/6] [REF] contacts: set mail module as dependency of contacts Contact application allows notably to see the activity summary view on customers activities. It require mail to be installed. As there is no real use of contacts application without mail let us set mail as a dependency of contacts. It seems a better solution than having a bridge module between contacts and mail. This commit is linked to task ID 1882545 and PR #26797. --- addons/contacts/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/contacts/__manifest__.py b/addons/contacts/__manifest__.py index 1df86af5667..5eef2f47a17 100644 --- a/addons/contacts/__manifest__.py +++ b/addons/contacts/__manifest__.py @@ -10,7 +10,7 @@ This module gives you a quick view of your contacts directory, accessible from your home page. You can track your vendors, customers and other contacts. """, - 'depends': ['base'], + 'depends': ['base', 'mail'], 'data': [ 'views/contact_views.xml', ], From db3cdee226eb4e137bf2e388171a3f1299e5a1bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 5 Sep 2018 11:39:56 +0200 Subject: [PATCH 2/6] [FIX] note: use calendar icon when setting the reminder date in systray Specifications : * clock icon is generally used for datetime; * calendar icon is generally used for date; * as we set the reminder date in the systray let us use the calendar icon in the systray in the reminder section; * please also remove the extra margin bottom of note when entering a new reminder, it makes @est-odoo very sad; This commit is linked to task ID 1882545 and PR #26797. --- addons/note/static/src/scss/note.scss | 4 ++++ addons/note/static/src/xml/systray.xml | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/note/static/src/scss/note.scss b/addons/note/static/src/scss/note.scss index a1d4227e182..e7bc23fb855 100644 --- a/addons/note/static/src/scss/note.scss +++ b/addons/note/static/src/scss/note.scss @@ -37,6 +37,7 @@ display: flex; p { flex: 1 1 auto; + margin-bottom: 0px; } } .o_note_save { @@ -60,4 +61,7 @@ } } } + .o_note_set_datetime { + color: $text-muted; + } } diff --git a/addons/note/static/src/xml/systray.xml b/addons/note/static/src/xml/systray.xml index 56693a14544..8f0e953d94f 100644 --- a/addons/note/static/src/xml/systray.xml +++ b/addons/note/static/src/xml/systray.xml @@ -14,8 +14,8 @@ Add a note From 11918bbf4318e6c75733fb5fa7077f642fa673de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 5 Sep 2018 13:12:40 +0200 Subject: [PATCH 3/6] [FIX] mail: use contact app icon for partner-related activities in systray As res.partner model is defined in base systray takes the base icon as icon used in the systray when classifying activities by model. As base module has no icon it leads to a blank icon being displayed in the systray. Purpose of this commit is to use the icon from Contact application instead. As contacts application now depends on mail we do it simply through inheriting the systray_get_activities method that return the data to display the systray elements. This commit is linked to task ID 1882545 and PR #26797. --- addons/contacts/__init__.py | 2 ++ addons/contacts/models/__init__.py | 4 ++++ addons/contacts/models/res_users.py | 20 ++++++++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 addons/contacts/models/__init__.py create mode 100644 addons/contacts/models/res_users.py diff --git a/addons/contacts/__init__.py b/addons/contacts/__init__.py index 67dee8c60db..dc5e6b693d1 100644 --- a/addons/contacts/__init__.py +++ b/addons/contacts/__init__.py @@ -1,2 +1,4 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import models diff --git a/addons/contacts/models/__init__.py b/addons/contacts/models/__init__.py new file mode 100644 index 00000000000..74f3017f7e6 --- /dev/null +++ b/addons/contacts/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import res_users diff --git a/addons/contacts/models/res_users.py b/addons/contacts/models/res_users.py new file mode 100644 index 00000000000..04e16b713c6 --- /dev/null +++ b/addons/contacts/models/res_users.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import api, models, modules + + +class Users(models.Model): + _name = 'res.users' + _inherit = ['res.users'] + + @api.model + def systray_get_activities(self): + """ Update the systray icon of res.partner activities to use the + contact application one instead of base icon. """ + activities = super(Users, self).systray_get_activities() + for activity in activities: + if activity['model'] != 'res.partner': + continue + activity['icon'] = modules.module.get_module_icon('contacts') + return activities From 540226d806660f40c5d9116ece9acf0fbcf40d8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 5 Sep 2018 13:11:10 +0200 Subject: [PATCH 4/6] [IMP] mail, contacts: allow to have actions in systray elements Purpose of this commit is to allow having an icon redirecting to the activity summary view in the partner activities section of systray. This is done by supporting an additional 'actions' list in the activity data given to the systray. It displays small icons that redirect to an Odoo action given its xml ID. This commit is linked to task ID 1882545 and PR #26797. --- addons/contacts/models/res_users.py | 5 +++++ addons/contacts/views/contact_views.xml | 16 ++++++++++++++++ .../src/js/systray/systray_activity_menu.js | 12 ++++++++++++ addons/mail/static/src/scss/discuss.scss | 12 +++++++++++- addons/mail/static/src/xml/systray.xml | 11 +++++++++++ 5 files changed, 55 insertions(+), 1 deletion(-) diff --git a/addons/contacts/models/res_users.py b/addons/contacts/models/res_users.py index 04e16b713c6..3a42daaa007 100644 --- a/addons/contacts/models/res_users.py +++ b/addons/contacts/models/res_users.py @@ -17,4 +17,9 @@ class Users(models.Model): if activity['model'] != 'res.partner': continue activity['icon'] = modules.module.get_module_icon('contacts') + activity['actions'] = [{ + 'icon': 'fa-clock-o', + 'name': 'Summary', + 'action_xmlid': 'contacts.action_contacts_summary' + }] return activities diff --git a/addons/contacts/views/contact_views.xml b/addons/contacts/views/contact_views.xml index 82da7aaca6b..efedaa7b393 100644 --- a/addons/contacts/views/contact_views.xml +++ b/addons/contacts/views/contact_views.xml @@ -34,6 +34,22 @@ + + Contacts + ir.actions.act_window + res.partner + form + activity,kanban,tree,form + + +

+ Create a contact in your address book +

+ Odoo helps you to easily track all activities related to a customer. +

+
+
+ +
+ + + +
From a75b7cd51717f983c93dafd651f4580cba94c21e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 5 Sep 2018 13:36:06 +0200 Subject: [PATCH 5/6] [IMP] mail: sort activity summary view by deadline ascending Purpose of this commit is to have first activities to perform displayed first in the activities summary view. This commit is linked to task ID 1882545 and PR #26797. --- addons/mail/models/mail_activity.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/addons/mail/models/mail_activity.py b/addons/mail/models/mail_activity.py index 234634863b5..78b4b005f77 100644 --- a/addons/mail/models/mail_activity.py +++ b/addons/mail/models/mail_activity.py @@ -408,16 +408,22 @@ class MailActivity(models.Model): def get_activity_data(self, res_model, domain): res = self.env[res_model].search(domain) activity_domain = [('res_id', 'in', res.ids), ('res_model', '=', res_model)] - grouped_activities = self.env['mail.activity'].read_group(activity_domain, ['res_id', 'activity_type_id', 'res_name:max(res_name)', 'ids:array_agg(id)', 'date_deadline:min(date_deadline)'], ['res_id', 'activity_type_id'], lazy=False) + grouped_activities = self.env['mail.activity'].read_group( + activity_domain, + ['res_id', 'activity_type_id', 'res_name:max(res_name)', 'ids:array_agg(id)', 'date_deadline:min(date_deadline)'], + ['res_id', 'activity_type_id'], + lazy=False) activity_type_ids = self.env['mail.activity.type'] - res_list = set() + res_id_to_name = {} + res_id_to_deadline = {} activity_data = defaultdict(dict) for group in grouped_activities: res_id = group['res_id'] res_name = group['res_name'] activity_type_id = group['activity_type_id'][0] activity_type_ids |= self.env['mail.activity.type'].browse(activity_type_id) # we will get the name when reading mail_template_ids - res_list.add((res_id, res_name)) + res_id_to_name[res_id] = res_name + res_id_to_deadline[res_id] = group['date_deadline'] if (res_id not in res_id_to_deadline or group['date_deadline'] < res_id_to_deadline[res_id]) else res_id_to_deadline[res_id] state = self._compute_state_from_date(group['date_deadline'], self.user_id.sudo().tz) activity_data[res_id][activity_type_id] = { 'count': group['__count'], @@ -426,6 +432,7 @@ class MailActivity(models.Model): 'state': state, 'o_closest_deadline': group['date_deadline'], } + res_ids_sorted = sorted(res_id_to_deadline, key=lambda item: res_id_to_deadline[item]) activity_type_infos = [] for elem in activity_type_ids: mail_template_info = [] @@ -435,7 +442,7 @@ class MailActivity(models.Model): return { 'activity_types': activity_type_infos, - 'res_ids': list(res_list), + 'res_ids': [(rid, res_id_to_name[rid]) for rid in res_ids_sorted], 'grouped_activities': activity_data, 'model': res_model, } From 9abbd843a85868c2e3a0bd39454c9a1347fccdf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 5 Sep 2018 13:40:25 +0200 Subject: [PATCH 6/6] [FIX] mail: set cursor as pointer when hovering contact name in activity summary view Purpose of this commit is to make it obvious contact name cell is clickable. This commit is linked to task ID 1882545 and PR #26797. --- addons/mail/static/src/scss/activity_view.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/mail/static/src/scss/activity_view.scss b/addons/mail/static/src/scss/activity_view.scss index fb88d61e8b1..f1eda8ae86a 100644 --- a/addons/mail/static/src/scss/activity_view.scss +++ b/addons/mail/static/src/scss/activity_view.scss @@ -33,6 +33,7 @@ color: #008784; &:hover { color: #666; + cursor: pointer; } cursor: pointer; }