Contributors mailing list archives


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

DEC, Yann Papouin
- 30/06/2022 14:52:58

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