'Set the buttons in node to readonly if the user can\'t activate them.'

@api.model
def _disable_workflow_buttons(self, model, node):

    if ((model is None) or (self.env.user.id == SUPERUSER_ID)):
        return node
    user_group_ids = set(self.env.user.groups_id.ids)
    buttons = (n for n in node.getiterator('button') if (n.get('type') != 'object'))
    for button in buttons:
        query = 'SELECT    DISTINCT    t.group_id\n                                                                                                    FROM    wkf\n                                                                            INNER    JOIN    wkf_activity    a    ON    a.wkf_id    =    wkf.id\n                                                                            INNER    JOIN    wkf_transition    t    ON    (t.act_to    =    a.id)\n                                                                                                WHERE    wkf.osv    =    %s\n                                                                                                        AND    t.signal    =    %s\n                                                                                                        AND    t.group_id    is    NOT    NULL'
        self._cr.execute(query, (model, button.get('name')))
        group_ids = set((row[0] for row in self._cr.fetchall() if row[0]))
        can_click = ((not group_ids) or bool((user_group_ids & group_ids)))
        button.set('readonly', str(int((not can_click))))
    return node
