'Monkey-patch a method for all instances of this model. This replaces
the method called ``name`` by ``method`` in the given class.
The original method is then accessible via ``method.origin``, and it
can be restored with :meth:`~._revert_method`.
Example::
@api.multi
def do_write(self, values):
# do stuff, and call the original method
return do_write.origin(self, values)
# patch method write of model
model._patch_method(\'write\', do_write)
# this will call do_write
records = model.search([...])
records.write(...)
# restore the original method
model._revert_method(\'write\')'

@classmethod
def _patch_method(cls, name, method):

    origin = getattr(cls, name)
    method.origin = origin
    wrapped = api.guess(api.propagate(origin, method))
    wrapped.origin = origin
    setattr(cls, name, wrapped)
