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
scenario--
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" />
</xpath>