Contributors mailing list archives


Re: Overwriting a method in OCA module.

Opener B.V., Stefan Rijnhart
- 13/09/2015 00:25:12
Sure Arnold, see here:

On September 12, 2015 7:52:53 PM CEST, David Arnold <> wrote:

Hi Stefan, do you know of a code example where you can point me to? I'm interested in that kind of advanced tricks.. Best, David

Stefan Rijnhart <> schrieb am Sa., 12. Sep. 2015 um 09:52:
On 12-09-15 00:37, Nhomar Hernandez wrote:
> 1.- Overwrite the method in a module which split (refactoring it) the
> mega method in several mini methods and/or hooks. (this is module1 and
> propose to OCA explaining why for stable-version).

Good idea to overwrite the method in a module that introduces the hooks
but does not change anything functional!

To preserve any existing inheritance, you could in such a module replace
the original method with the refactored version by applying it as a
monkeypatch in _register_hook. While it will still affect all databases
on the instance once the module is installed, it will not be preloaded
if the module is only in the module path and not installed on any
database. That trick is courtesy of Holger Brunn, BTW.


Post to:

Post to:

Sent from my Android device with K-9 Mail. Please excuse my brevity.