Jaime Arroyo
6 years ago
8 changed files with 173 additions and 2 deletions
-
5mail_activity_team/__manifest__.py
-
1mail_activity_team/models/__init__.py
-
24mail_activity_team/models/mail_activity_mixin.py
-
49mail_activity_team/models/res_users.py
-
70mail_activity_team/static/src/js/systray.js
-
15mail_activity_team/static/src/xml/systray.xml
-
9mail_activity_team/views/assets_backend.xml
-
2mail_activity_team/views/mail_activity_views.xml
@ -1,3 +1,4 @@ |
|||||
from . import mail_activity_team |
from . import mail_activity_team |
||||
from . import mail_activity |
from . import mail_activity |
||||
from . import res_users |
from . import res_users |
||||
|
from . import mail_activity_mixin |
@ -0,0 +1,24 @@ |
|||||
|
# Copyright 2018 Eficent Business and IT Consulting Services, S.L. |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
||||
|
from odoo import api, models, fields, _ |
||||
|
from odoo.exceptions import ValidationError |
||||
|
|
||||
|
|
||||
|
class MailActivityMixin(models.AbstractModel): |
||||
|
_inherit = 'mail.activity.mixin' |
||||
|
|
||||
|
activity_team_user_ids = fields.Many2many( |
||||
|
comodel_name='res.users', string='test field', |
||||
|
compute="_compute_activity_team_user_ids", |
||||
|
search="_search_activity_team_user_ids", |
||||
|
) |
||||
|
|
||||
|
@api.depends("activity_ids") |
||||
|
def _compute_activity_team_user_ids(self): |
||||
|
for rec in self: |
||||
|
rec.activity_team_user_ids = rec.activity_ids.mapped( |
||||
|
"team_id.member_ids") |
||||
|
|
||||
|
@api.model |
||||
|
def _search_activity_team_user_ids(self, operator, operand): |
||||
|
return [('activity_ids.team_id.member_ids', operator, operand)] |
@ -0,0 +1,70 @@ |
|||||
|
odoo.define('mail_activity_team.systray', function (require) { |
||||
|
"use strict"; |
||||
|
|
||||
|
var systray = require('mail.systray'); |
||||
|
var session = require("web.session"); |
||||
|
|
||||
|
systray.ActivityMenu.include({ |
||||
|
events: _.extend({}, systray.ActivityMenu.prototype.events, { |
||||
|
'click .o_filter_button': 'on_click_filter_button', |
||||
|
}), |
||||
|
start: function() { |
||||
|
this._super.apply(this, arguments); |
||||
|
this.$filter_buttons = this.$('.o_filter_button'); |
||||
|
this.filter = 'my'; |
||||
|
}, |
||||
|
on_click_filter_button: function (event) { |
||||
|
var self = this; |
||||
|
|
||||
|
event.stopPropagation(); |
||||
|
self.$filter_buttons.removeClass('active'); |
||||
|
var $target = $(event.currentTarget); |
||||
|
$target.addClass('active'); |
||||
|
self.filter = $target.data('filter'); |
||||
|
if (self.filter == 'team'){ |
||||
|
session.user_context = _.extend({}, session.user_context, { |
||||
|
'team_activities': true |
||||
|
}); |
||||
|
} |
||||
|
else if (self.filter == 'my'){ |
||||
|
session.user_context = _.extend({}, session.user_context, { |
||||
|
'team_activities': false |
||||
|
}); |
||||
|
} |
||||
|
self._updateActivityPreview(); |
||||
|
|
||||
|
}, |
||||
|
_onActivityFilterClick: function (event){ |
||||
|
if (this.filter == 'my'){ |
||||
|
this._super.apply(this, arguments); |
||||
|
} |
||||
|
if (this.filter == 'team'){ |
||||
|
var data = _.extend({}, $(event.currentTarget).data(), $(event.target).data()); |
||||
|
var context = {}; |
||||
|
if (data.filter === 'my') { |
||||
|
context['search_default_activities_overdue'] = 1; |
||||
|
context['search_default_activities_today'] = 1; |
||||
|
} else { |
||||
|
context['search_default_activities_' + data.filter] = 1; |
||||
|
} |
||||
|
this.do_action({ |
||||
|
type: 'ir.actions.act_window', |
||||
|
name: data.model_name, |
||||
|
res_model: data.res_model, |
||||
|
views: [[false, 'kanban'], [false, 'form']], |
||||
|
search_view_id: [false], |
||||
|
domain: ['|', ['activity_user_id', '=', session.uid], ['activity_team_user_ids', 'in', session.uid]], |
||||
|
context:context, |
||||
|
}); |
||||
|
} |
||||
|
}, |
||||
|
/* |
||||
|
_getActivityData: function(){ |
||||
|
var self = this; |
||||
|
this._super.apply(this, arguments).then(function () { |
||||
|
|
||||
|
}); |
||||
|
},*/ |
||||
|
}); |
||||
|
|
||||
|
}); |
@ -0,0 +1,15 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<templates> |
||||
|
|
||||
|
<t t-extend="mail.chat.ActivityMenu"> |
||||
|
<t t-jquery=".o_mail_navbar_dropdown_channels" t-operation="before"> |
||||
|
<li class="o_mail_navbar_dropdown_top"> |
||||
|
<div> |
||||
|
<button type="button" class="btn btn-sm o_filter_button active" data-filter='my'> My Activities </button> |
||||
|
<button type="button" class="btn btn-sm o_filter_button" data-filter='team'> Team Activities </button> |
||||
|
</div> |
||||
|
</li> |
||||
|
</t> |
||||
|
</t> |
||||
|
|
||||
|
</templates> |
@ -0,0 +1,9 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<odoo> |
||||
|
<template id="assets_backend" name="mail assets" |
||||
|
inherit_id="web.assets_backend"> |
||||
|
<xpath expr="." position="inside"> |
||||
|
<script type="text/javascript" src="/mail_activity_team/static/src/js/systray.js"/> |
||||
|
</xpath> |
||||
|
</template> |
||||
|
</odoo> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue