Contributors mailing list archives
Re: Overwriting a method in OCA module.by
Opener B.V., Stefan Rijnhart
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. Regards, Stefan.