Skip to Content
Menu
This question has been flagged
4828 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(%)'),

    }




Avatar
Discard