Skip to Content
Menu
This question has been flagged
4 Replies
1895 Views

I am  trying to add tax into invoice line by doing

discount_l.write({'tax_ids': tax_ids})

which did add tax into 'account_move_line' but the total of invoice did not change. I try debug and notice that onchange method did not trigger. I read some document and onchange only triggers on FORM. What should I do? I dont know how many onchange methods I need to call manually

Avatar
Discard
Author Best Answer

ok guys, here is the solution I found on stackoverflow

account_invoice.write(
{'invoice_line_ids': [Command.update(invoice_line_to_update.id, {'tax_ids': tax_ids})]})


Avatar
Discard
Best Answer

Well, The simplest solution is to call your on change function in your new function for example :

@api.onchange('tax_ids'):

 def compute_tax(self):

   #Your code 

def your other function_to assign taxed(self):

    

discount_l.write({'tax_ids': tax_ids})

    self.compute_tax()


    

    

Avatar
Discard
Author

the problem is i want to call onchange method of the odoo code base, which i don't know how many onchange method actually involves

Best Answer

Hi,

Try as follows:

   discount_l.write({'tax_ids': tax_ids})
invoice_line._onchange_price_subtotal()
invoice_id._recompute_dynamic_lines(
recompute_all_taxes=True,
recompute_tax_base_amount=True,
)



Thanks & Regards

Avatar
Discard
Author

Your solution gives me
'The amount expressed in the secondary currency must be positive when account is debited and negative when account is credited. If the currency is the same as the one from the company, this amount must strictly be equal to the balance.'

Best Answer

Hello Odoo Learner,

Onchange method only trigger when you make any changes on field from user interface but in this case you can manually call onchange method just after writing tax as below..

discount_l.write({'tax_ids': tax_ids})
discount_l._onchange_price_subtotal()

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

Avatar
Discard
Related Posts Replies Views Activity
2
Nov 24
267
1
Oct 24
335
4
Oct 24
325
2
Oct 24
362
2
Dec 24
670