You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1.1 KiB

  1. # Copyright 2018 David Juaneda - <djuaneda@sdi.es>
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  3. from odoo import models
  4. class MailActivityMixin(models.AbstractModel):
  5. _inherit = 'mail.activity.mixin'
  6. def redirect_to_activities(self, **kwargs):
  7. """Redirects to the list of activities of the object shown.
  8. Redirects to the activity board and configures the domain so that
  9. only those activities that are related to the object shown are
  10. displayed.
  11. Add to the title of the view the name the class of the object from
  12. which the activities will be displayed.
  13. :param kwargs: contains the id of the object and the model it's about.
  14. :return: action.
  15. """
  16. _id = kwargs.get("id")
  17. action = self.env['mail.activity'].action_activities_board()
  18. views = []
  19. for v in action['views']:
  20. if v[1] == 'tree':
  21. v = (v[0], 'list')
  22. views.append(v)
  23. action['views'] = views
  24. action['domain'] = [('res_id', '=', _id)]
  25. return action