I want to override a original field function in Odoo.
According to the answer here: Odoo: How to override original function i just have to define exactly the same method as in the original model. So here is my code:
class paiement_client_difference_montant(models.Model):
_inherit="account.voucher"
#writeoff_amount=fields.Float(compute='_get_writeoff_amount')
def _get_writeoff_amount(self, cr, uid, ids, name, args, context=None):
print '_get_writeoff_amount _inherit'
if not ids: return {}
currency_obj = self.pool.get('res.currency')
res = {}
for voucher in self.browse(cr, uid, ids, context=context):
debit = credit = 0.0
sign = voucher.type == 'payment' and -1 or 1
for l in voucher.line_dr_ids:
debit += l.amount
for l in voucher.line_cr_ids:
credit += l.amount
currency = voucher.currency_id or voucher.company_id.currency_id
res[voucher.id] = currency_obj.round(cr, uid, currency, voucher.amount - sign * (credit - debit))
return res
But that code is never reached. Any help please. Thank you.
account.voucher
because the inherit field was outside the class block – danideewriteoff_amount
. It's a comment.By the way i've tried with your change and it still doesn't work. – Oumar Diarrawriteoff_amount
is a field in baseaccount.voucher
? – gabrieloliveira_inherit = account.voucher
it was outside the class block....i edited your question and fixed it. – danidee