2018-11-02 10:38:21 +01:00
|
|
|
# Copyright 2018 David Juaneda - <djuaneda@sdi.es>
|
2021-01-22 10:36:00 +01:00
|
|
|
# Copyright 2021 Sodexis
|
2018-11-02 10:38:21 +01:00
|
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
|
|
|
from odoo import models
|
|
|
|
|
|
|
|
|
|
|
|
class MailActivityMixin(models.AbstractModel):
|
2019-10-23 12:19:26 +02:00
|
|
|
_inherit = "mail.activity.mixin"
|
2018-11-02 10:38:21 +01:00
|
|
|
|
|
|
|
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.
|
|
|
|
"""
|
2018-12-03 11:58:09 +01:00
|
|
|
_id = kwargs.get("id")
|
2021-01-22 10:36:00 +01:00
|
|
|
model = kwargs.get("model")
|
2019-10-23 12:19:26 +02:00
|
|
|
action = self.env["mail.activity"].action_activities_board()
|
2018-11-02 10:38:21 +01:00
|
|
|
views = []
|
2019-10-23 12:19:26 +02:00
|
|
|
for v in action["views"]:
|
|
|
|
if v[1] == "tree":
|
|
|
|
v = (v[0], "list")
|
2018-11-02 10:38:21 +01:00
|
|
|
views.append(v)
|
2019-10-23 12:19:26 +02:00
|
|
|
action["views"] = views
|
2021-01-22 10:36:00 +01:00
|
|
|
action["domain"] = [("res_id", "=", _id), (("res_model", "=", model))]
|
2018-11-02 10:38:21 +01:00
|
|
|
return action
|