Contributors mailing list archives

contributors@odoo-community.org

Browse archives

Avatar

Re: Overwriting a method in OCA module.

by
dar@devco.co
- 13/09/2015 04:46:07

Thx!

Stefan Rijnhart <stefan@opener.am> schrieb am Sa., 12. Sep. 2015 um 17:37:

Sure Arnold, see here: https://github.com/Therp/Therp-Addons/blob/7.0/mail_error/model/mail_mail_monkeypatch.py

On September 12, 2015 7:52:53 PM CEST, David Arnold <dar@devco.co> 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 <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

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

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

_______________________________________________

Reference