Skip to content

Commit

Permalink
[REF] mail, note: rename systray method giving data for web client
Browse files Browse the repository at this point in the history
As it becomes used to display more things than just counting activities let
us rename the method. Future commits will add new features in the systray
like meetings.

This commit is linked to task ID 60593.
  • Loading branch information
mba-odoo authored and tde-banana-odoo committed May 31, 2018
1 parent 3239c91 commit 6429704
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion addons/mail/models/res_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def write(self, vals):
return write_res

@api.model
def activity_user_count(self):
def systray_get_activities(self):
query = """SELECT m.id, count(*), act.res_model as model,
CASE
WHEN %(today)s::date - act.date_deadline::date = 0 Then 'today'
Expand Down
2 changes: 1 addition & 1 deletion addons/mail/static/src/js/systray.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ var ActivityMenu = Widget.extend({

return self._rpc({
model: 'res.users',
method: 'activity_user_count',
method: 'systray_get_activities',
kwargs: {
context: session.user_context,
},
Expand Down
4 changes: 2 additions & 2 deletions addons/mail/static/tests/systray_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ QUnit.test('activity menu widget: menu with no records', function (assert) {
testUtils.addMockEnvironment(activityMenu, {
services: this.services,
mockRPC: function (route, args) {
if (args.method === 'activity_user_count') {
if (args.method === 'systray_get_activities') {
return $.when([]);
}
return this._super(route, args);
Expand All @@ -79,7 +79,7 @@ QUnit.test('activity menu widget: activity menu with 3 records', function (asser
testUtils.addMockEnvironment(activityMenu, {
services: this.services,
mockRPC: function (route, args) {
if (args.method === 'activity_user_count') {
if (args.method === 'systray_get_activities') {
return $.when(self.data['mail.activity.menu']['records']);
}
return this._super(route, args);
Expand Down
4 changes: 2 additions & 2 deletions addons/note/models/res_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ def _create_note_stages(self):
_logger.info('Note default columns created for user id %s', user.id)

@api.model
def activity_user_count(self):
def systray_get_activities(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()
activities = super(Users, self).systray_get_activities()
notes_count = self.env['note.note'].search_count([('user_id', '=', self.env.uid)])
if notes_count:
note_index = next((index for (index, a) in enumerate(activities) if a["model"] == "note.note"), None)
Expand Down
2 changes: 1 addition & 1 deletion addons/note/static/tests/systray_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ QUnit.test('note activity menu widget: create note from activity menu', function
testUtils.addMockEnvironment(activityMenu, {
services: this.services,
mockRPC: function (route, args) {
if (args.method === 'activity_user_count') {
if (args.method === 'systray_get_activities') {
return $.when(self.data['mail.activity.menu']['records']);
}
if (route === '/note/new') {
Expand Down

0 comments on commit 6429704

Please sign in to comment.