Contributors mailing list archives

contributors@odoo-community.org

Re: Overwriting a method in OCA module.

by
Opener B.V., Stefan Rijnhart
- 28/09/2015 19:55:38
On 28-09-15 05:23, Kitti U. wrote:
<blockquote cite="mid:CAKNFPG7XQUWFVLVSNc0eJkxPvFZo5ca2ke=d1_1KEBAB=h4uSA@mail.gmail.com" type="cite">
Hello.

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 https://github.com/Therp/Therp-Addons/blob/7.0/mail_error/model/mail_mail_monkeypatch.py

as 


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


Hi Kitti U.,

I had to look twice myself, but with this change it works:

--- a/account_billing_hook_recompute_vline/account_voucher_hook_recompute_vline.py
+++ b/account_billing_hook_recompute_vline/account_voucher_hook_recompute_vline.py
@@ -19,7 +19,7 @@
 #
 
 from openerp import models
-from openerp.addons.account_voucher import account_voucher
+from openerp.addons.account_voucher.account_voucher import account_voucher
 
 
 def recompute_voucher_lines(self, cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, date, context=None):


You were importing the account_voucher.py, but we want the account_voucher object in this file.

Regards,
Stefan.

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

Stefan Rijnhart - Consultant/developer

mail: stefan@opener.am
tel: +31 (0) 20 3090 139
web: https://opener.am