Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
4 Replies
2807 Tampilan

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
Buang
Penulis Jawaban Terbai

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
Buang
Jawaban Terbai

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
Buang
Penulis

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

Jawaban Terbai

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
Buang
Penulis

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

Jawaban Terbai

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
Buang
Post Terkait Replies Tampilan Aktivitas
2
Agu 25
2450
1
Jul 25
922
1
Agu 25
1151
0
Mei 25
1365
2
Apr 25
3576