跳至內容
選單
此問題已被標幟
4 回覆
2810 瀏覽次數

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

頭像
捨棄
作者 最佳答案

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})]})


頭像
捨棄
最佳答案

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()


    

    

頭像
捨棄
作者

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

最佳答案

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

頭像
捨棄
作者

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

最佳答案

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

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
2
8月 25
2481
1
7月 25
941
1
8月 25
1151
0
5月 25
1381
2
4月 25
3583