Contributors mailing list archives

contributors@odoo-community.org

Browse archives

Avatar

Tip: Always call `clean_action` when returning an `ir.actions.act_window`

by
DEC, Yann Papouin
- 30/06/2022 16:52:58
Hi,

Simple tip after losing my afternoon on this:
If you add a python `action_open_view_xxx` code that returns an `ir.actions.act_window` dict, you should always use the built-in `clean_action` that will convert any `tree` to `list`, otherwise the list view will be missing from the web client.
Note that this fix is always done internally by the webclient.

from odoo.addons.web.controllers.main import clean_action

class ProjectProject(models.Model):
    _inherit = 'project.project'

    def action_open_all_tasks(self, view_domain=False, view_type=False):
        act = clean_action(self.env.ref("project.action_view_task").read()[0])         return act


--
Yann PAPOUIN, Ingénieur R&D | DEC