Odoo Help

Welcome!

This community 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.

0

Herite and Change a fonction?

By
elalaoui
on 5/22/15, 5:53 AM 514 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)

1

Ivan

--Ivan--
3210
| 5 3 6
Jakarta, Indonesia
--Ivan--
Ivan
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.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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