Odoo Help


How to update invoice Subtotal with a new custom field in Sale.order form ?

on 3/25/15, 4:27 AM 800 views

I have to  add a custom field in 'sale.order'  form ,after that I can override  _amount_all method from sale.order
inside this function I can alter the existing sale order subtotal calculation with my new custom field ('tax_new': fields.float('Taxes in(%)').
But this Total value  from sale.order (with my custom field calculation) is not Updated when I create the invoice
How to change my below code ?----------- So How to add/override invoice method for updating my custom field into invoice.Need a help......

class sale_order(osv.Model):

    _inherit = "sale.order"

    _description = "Validate quote"


    def _amount_all(self, cr, uid, ids, field_name, arg, context=None):

        cur_obj = self.pool.get('res.currency')

        res = {}

        for order in self.browse(cr, uid, ids, context=context):

            res[order.id] = {

                'amount_untaxed': 0.0,

                'amount_tax': 0.0,

                'amount_total': 0.0,



            print "tax",res[order.id]['amount_untaxed']


            val = val1 = 0.0

            cur = order.pricelist_id.currency_id

            for line in order.order_line:

                val1 += line.price_subtotal

                val += self._amount_line_tax(cr, uid, line, context=context)

            res[order.id]['amount_tax'] = cur_obj.round(cr, uid, cur, val)

            res[order.id]['amount_untaxed'] = cur_obj.round(cr, uid, cur, val1)

            res = super(sale_order, self)._amount_all(cr, uid, ids, field_name, arg, context

            res[order.id]['amount_total'] = res[order.id]['amount_tax']+res[order.id]['amount_untaxed']+res[order.id]['amount_untaxed']*(order['tax_new']/100)

        return res

 _columns = {

                'tax_new': fields.float('Taxes in(%)'),


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: 3/25/15, 4:27 AM
Seen: 800 times
Last updated: 3/25/15, 6:00 AM