My task is when onchangeof invoice_line_tax_id from customer invoice line then it result should be
result=new_total+invoice_line_tax_id ,But i cannt get the result when the onchange of invoice_line_tax_id is changes.How to resolve this issue.Please need a help
This is the onchange method
#def onchange_tax_id(self,cr,uid,ids,invoice_line_tax_id,context=None):
from osv import osv,fields
class account_new(osv.osv):
_inherit='account.invoice.line'
def onchange_schemid(self,cr,uid,ids,price_unit,quantity,context=None):
if price_unit:
amount_new=price_unit*quantity
return {'value':{'new_total':amount_new}}
return {}
def onchange_tax_id(self,cr,uid,ids,invoice_line_tax_id,context=None):
a=self.pool.get('account.invoice.line').read(cr,uid,['new_total'],context=context)
b=self.pool.get('account.tax').read(cr,uid,['invoice_line_tax_id'],context=context)
if invoice_line_tax_id:
val1=a[0]['new_total']
val2=b[0]['invoice_line_tax_id']
amount_with_tax=val1+val2
return {'value':{'new_with_tax':amount_with_tax}}
return {}
_columns={
'new_total': fields.integer('Gross Amount', required=True),
'new_with_tax':fields.float('Amount')
}
account_new()
EDIT------------
.xml file
<xpath expr="/form/sheet/notebook/page[1]/field[1]/tree/field[11]" position="inside">
<field name="invoice_line_tax_id" on_change="onchange_tax_id(invoice_line_tax_id)"/>
</xpath>
.py file
class account_new(osv.osv):
_inherit='account.invoice.line'
def onchange_schemid(self,cr,uid,ids,price_unit,quantity,context=None):
if price_unit:
amount_new=price_unit*quantity
return {'value':{'new_total':amount_new}}
return {}
def onchange_tax_id(self,cr,uid,ids,invoice_line_tax_id,context=None):
acc_tax_obj = self.pool.get('account.tax')
line_tax = invoice_line_tax_id
for val in acc_tax_obj.browse(cr, uid, line_tax);
amount = val.amount
return {'value':{'new_with_tax':amount}}
But this onchange is not working------------