social/mail_activity_board/models/mail_activity_mixin.py
Dajuayen a05dd4fda2 [ADD][mail_activity_board] Add new module that insert activities board in boards. (#283)
* [ADD] Module that insert activities board.

* [FIX] Author error in __manifest__ file and style changes.

* [FIX] Fix replace in view, rename files and style changes.

* [FIX] Enumerated list ends without a blank line; unexpected unindent.

* [FIX] Name fail.

* [FIX] Bug in view.

* [FIX]  Add button Activities in mail.thread and readme folder. Others improvements in style of code.

* [FIX] Type 'tree' not found in registry: problem solved.

* [FIX] Dependence change: 'mail' for 'calendar'.

* [FIX] Eliminated unnecessary imports.

* [FIX] Bugs about js and if/else.

* [FIX] Improvements following guide lines and eliminating unnecessary attributes in views.

* [ADD] Added counter in the 'Activities List' button.

* [FIX] Bugs in javascript with 'Activities' button.

* [ADD] Tests folder.

* [FIX] Deleted references to modules not installed.

* [FIX] Formatting javascript.

* [FIX] Bug: added a soft line before a class.

* [FIX] Bug: https://github.com/OCA/social/pull/283#discussion_r204302325

* [FIX] Escaping 'lt' in xml file. Bug: https://github.com/OCA/social/pull/283#discussion_r204302325

* [FIX] The meeting attendees are shown in kanban mode on the meeting board.

* [FIX] Hide in form view of the activity board the assistant field if the activity is not a meeting type or if there are no assistants.

* [FIX] Change to default kanban view for partners.
2022-11-29 18:51:29 -03:00

33 lines
1.1 KiB
Python

# Copyright 2018 David Juaneda - <djuaneda@sdi.es>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models
class MailActivityMixin(models.AbstractModel):
_inherit = 'mail.activity.mixin'
def redirect_to_activities(self, **kwargs):
"""Redirects to the list of activities of the object shown.
Redirects to the activity board and configures the domain so that
only those activities that are related to the object shown are
displayed.
Add to the title of the view the name the class of the object from
which the activities will be displayed.
:param kwargs: contains the id of the object and the model it's about.
:return: action.
"""
id = kwargs.get("id")
action = self.env['mail.activity'].action_activities_board()
views = []
for v in action['views']:
if v[1] == 'tree':
v = (v[0], 'list')
views.append(v)
action['views'] = views
action['domain'] = [('res_id', '=', id)]
return action