Ir al contenido
Menú
Se marcó esta pregunta
4 Respuestas
2823 Vistas

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
Descartar
Autor Mejor respuesta

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
Descartar
Mejor respuesta

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
Descartar
Autor

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

Mejor respuesta

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
Descartar
Autor

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.'

Mejor respuesta

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
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
2
ago 25
2517
1
jul 25
949
1
ago 25
1151
0
may 25
1393
2
abr 25
3591