'Binds an the given action to the given model\'s action slot - for later
retrieval via :meth:`~.get_actions`. Any existing binding of the same action
to the same slot is first removed, allowing an update of the action\'s name.
See the class description for more details about the various action
slots: :class:`~ir_values`.
:param string name: action label, usually displayed by UI client
:param string action_slot: the action slot to which the action should be
bound to - one of ``client_action_multi``,
``client_print_multi``, ``client_action_relate``,
``tree_but_open``.
:param string model: model name
:param string action: action reference, in the form ``\'model,id\'``
:param int res_id: optional record id - will bind the action only to a
specific record of the model, not all records.
:return: the newly created ir.values entry'

@api.model
@api.returns('self', (lambda value: value.id))
def set_action(self, name, action_slot, model, action, res_id=False):

    assert (isinstance(action, basestring) and (',' in action)), 'Action    definition    must    be    an    action    reference,    e.g.    "ir.actions.act_window,42"'
    assert (action_slot in ACTION_SLOTS), ('Action    slot    (%s)    must    be    one    of:    %r' % (action_slot, ACTION_SLOTS))
    search_criteria = [('key', '=', 'action'), ('key2', '=', action_slot), ('model', '=', model), ('res_id', '=', (res_id or 0)), ('value', '=', action)]
    self.search(search_criteria).unlink()
    return self.create({'key': 'action', 'key2': action_slot, 'model': model, 'res_id': res_id, 'name': name, 'value': action})
