Odoo Help


Herite and Change a fonction?

on 5/22/15, 5:53 AM 947 views

hello ,

# -*- coding: utf-8 -*-

from openerp.osv import osv, fields

class account_line(osv.osv):

_inherit = 'account.invoice.line'

_columns = {

'rem1': fields.float(string='Remise1'),

'rem2': fields.float(string='Remise2'),

'rem3': fields.float(string='Remise3'),

'gratuite_qte': fields.float(string='Gratuite_Qte'),


i want to herite a fonction from account.invoice.line module and change the column (price_subtotal = taxes['total'] + rem1) . this is fonction's code :

def _compute_price(self):

price = self.price_unit * (1 - (self.discount or 0.0) / 100.0)

print 'Prix : ',price

taxes = self.invoice_line_tax_id.compute_all(price, self.quantity, product=self.product_id, partner=self.invoice_id.partner_id)

print taxes['total']

self.price_subtotal = taxes['total']

if self.invoice_id:

self.price_subtotal = self.invoice_id.currency_id.round(self.price_subtotal)




| 5 3 6
Jakarta, Indonesia
On 5/22/15, 6:28 AM

You need to redefine all the function fields that uses _compute_price in your module.  You may want to use super() call instead of re-writing the whole thing again.  Also, be very careful with how you change compute_price.  It may affect taxation calculation.

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 5/22/15, 5:53 AM
Seen: 947 times
Last updated: 5/22/15, 10:38 AM