Odoo Help


Why Sale Order Total Amount is not updated in Invoice Total field in a custom Module?

on 3/19/15, 12:40 AM 1,293 views

In odoo 8 mondule I have add a custom tax field   ' tax_new '   in sale.order form this tax_new is updated with my new calculation .But when I create an invoice this new calculation with total amount(amount_total) is not reflected in My Customer invoice based on this sale order why?  

How to change my below code  need a help? Now I add tax_new field in account.invoie

then how to  pass the value from sale order to invoice for the new calculation with('tax_new' field)


in sale.order form

product          price   ....    qty ...........   total                  (This is sale order line sample )
 mobile          100         ....1      ..........  100

                                        subtotal=     100                                               

here I   add one field  (tax_new (%))        5 

                                       total=           105     (it means 100+ 100*5/ 100 (5 % tax from my field)   (This calculation is ok in sale.order)

But When I move to forward and  create Invoice only 100 is updated 5(my _custom tax field) is not updated

in the invoice total ..this is my issue  .So how to change my account.invoice code  

class sale_order(osv.Model):

    _inherit = "sale.order"

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

        print "############## INSide ###########"

        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)

            print "tax@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@",res

            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


'tax_new':fields.float('Tax in %')

.xml file****************************

<record id="view_order_form_double_validation" model="ir.ui.view">

<field name="name">sale.order.form</field>

<field name="model">sale.order</field>

<field name="inherit_id" ref="sale_stock.view_order_form_inherit"/>

<field name="arch" type="xml">



<xpath expr="/form/sheet/notebook/page/group/field[@name='amount_untaxed']" position="before">

<field name="tax_new" />




| 6 4 7
Lodz, Poland

On 3/25/15, 4:19 PM

You going to try to override the function _make_invoice() (from sale.py) and transfer tax_new from models sale.order to account.invoice. In both models you define stored tax_new field.

Hi Zibik thanks for ur replay ... i am rewrite my post ... and can you help me how to write my code in account.invoice

on 3/25/15, 10:36 PM

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 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/19/15, 12:40 AM
Seen: 1293 times
Last updated: 4/5/15, 9:58 PM