Odoo Help


change calcul taxe in sale_order_line

samir Guesmi
on 5/31/13, 1:24 PM 2,188 views

hi all , if someone can help , i try to mdofiy the rule to calculate taxes in sale order . i need that the taxes applied only for margin between ( price_unit and purchase_price ) there is a module named product_margin and sale_margin , he add a margin fields in the sale.order.line classes. i am using it , and i was add other class (sale.order.line ) and i try to override the _amount_line functions :

from openerp.osv import fields, osv

class sale_order_line(osv.osv):
    _inherit = "sale.order.line"

    def _amount_line(self, cr, uid, ids, field_name, arg, context=None):
        tax_obj = self.pool.get('account.tax')
        cur_obj = self.pool.get('res.currency')
        res = {}
        if context is None:
            context = {}
        for line in self.browse(cr, uid, ids, context=context):
            price = line.price_unit * (1 - (line.discount or 0.0) / 100.0)
            taxes = tax_obj.compute_all(cr, uid, line.tax_id, ***price ( replaced by line.margin)***, line.product_uom_qty, line.product_id, line.order_id.partner_id)
            cur = line.order_id.pricelist_id.currency_id
            res[line.id] = cur_obj.round(cr, uid, cur, taxes['total'])
        return res

but there is no change thanks




| 5 4 7
Baarn, Netherlands
On 5/31/13, 6:32 PM

Did you make these changes in a new module, or in the existing module?

In both cases, you need to restart the openerp Server, and reload the module (Settings -> Installed modules -> Select your own module or sale -> click on the button upgrade).

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

0 follower(s)


Asked: 5/31/13, 1:24 PM
Seen: 2188 times
Last updated: 3/16/15, 8:10 AM