Contributors mailing list archives


Re: Overwriting a method in OCA module.

Ecosoft Co. Ltd., Kitti Upariphutthiphong
- 28/09/2015 05:16:16

I have tested the monkey patch for account_billing module, which will PR to account-payment.

However, I follow the example here using _register_hook from


It doesn't work. The expected overwritten method in
is not being called ???

But if I use the same way as Nhomar, which is using normal _inherit way, it works as normal., but it wont't be as Stefan describeed

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.

Many thanks,
Kitti U.

On Thu, Sep 17, 2015 at 9:52 PM, Stefan Rijnhart <> wrote:
On 16-09-15 21:22, Nhomar Hernandez wrote:
<blockquote cite="" type="cite">

On Wed, Sep 16, 2015 at 7:53 AM, Kitti U. <> wrote:
(i.e., account_voucher_monkeypatch)

no **_monkeypatch on the name, a name that mention the monkeypatched method is more ellegant.

I think it should be in a "Good Practice technique section".


Opener B.V. - Business solutions driven by open source collaboration

Stefan Rijnhart - Consultant/developer

tel: +31 (0) 20 3090 139

Post to:

Mobile: +66-(0)8-1841-7480
Your ERP Partner =>