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

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

By
Odoo
on 3/25/15, 4:27 AM 388 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(%)'),

    }




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