'Compute an ordered list of the specific view modes that should be
enabled when displaying the result of this action, along with the
ID of the specific view to use for each mode, if any were required.
This function hides the logic of determining the precedence between
the view_modes string, the view_ids o2m, and the view_id m2o that
can be set on the action.'

@api.depends('view_ids.view_mode', 'view_mode', 'view_id.type')
def _compute_views(self):

    for act in self:
        act.views = [(view.view_id.id, view.view_mode) for view in act.view_ids]
        got_modes = [view.view_mode for view in act.view_ids]
        all_modes = act.view_mode.split(',')
        missing_modes = [mode for mode in all_modes if (mode not in got_modes)]
        if missing_modes:
            if (act.view_id.type in missing_modes):
                missing_modes.remove(act.view_id.type)
                act.views.append((act.view_id.id, act.view_id.type))
            act.views.extend([(False, mode) for mode in missing_modes])
