This question has been flagged
1 Reply
2525 Views

This is a one2many line from invoice line -Here i mentioned an example of sample product as service...

Product Service

Description xx

Account xx

Quantity- 1

Unit Price -10

Gross Amount -10(10*1)                             #This is a my own custom field[quantity*unitprice]

Taxes - 2

Amount  12(10+2)                               [Gross Amount+Taxes]

 

Above field values are from  customer invoice line from accounting  ,here I need one customization on invoice line  when onchage of taxes is change Amount should be changed ie(tax+gross amount) should populate in the Amount Field without pressing the update button .I need to change using tab (onchange of tax).How it is possible...Please need a help..........

Here I attached my code -----Please check

 

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,new_total,invoice_line_tax_id,context=None):
        a=self.pool.get('account.invoice.line').read(cr,uid,invoice_line_tax_id)
        if invoice_line_tax_id:
                amount_with_tax=new_total+invoice_line_tax_id
                return {'value':{'new_with_tax':amount_with_tax}}
        return {}
        
    _columns={
              'new_total': fields.float('Gross Amount', required=True),
              'new_with_tax':fields.float('Amount')
              }
    
    
account_new()

Avatar
Discard
Best Answer

Hi

Refer following link may help you

http://stackoverflow.com/questions/15608710/how-to-load-one-to-many-children-on-onchange-event

http://stackoverflow.com/questions/20954412/create-and-edit-items-of-a-one2many-field-through-on-change-method

Avatar
Discard