Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
4 Trả lời
2822 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

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


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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


    

    

Ảnh đại diện
Huỷ bỏ
Tác giả

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

Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Tác giả

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

Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 8 25
2517
1
thg 7 25
949
1
thg 8 25
1151
0
thg 5 25
1393
2
thg 4 25
3591