Contributors mailing list archives

contributors@odoo-community.org

Re: Overwriting a method in OCA module.

by
dar@devco.co
- 12/09/2015 16:40:26

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 <stefan@opener.am> 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.

Regards,
Stefan.

_______________________________________________
Mailing-List: http://odoo-community.org/groups/oca-contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: http://odoo-community.org/groups?unsubscribe