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

hi,

I have an invoice line, in which there are 2 different taxes. How can I know the index of a specific tax?
ex:
tax 1
tax 2
probe with: self.tax_line_ids [0] .amount_total

and it is correct, but the order of election of the tax is not always zero [0].
I need to replace the zero with the dynamic index.
Thank you,

for line in self.invoice_line_ids:

    for line2 in line.invoice_line_tax_ids:

          for line_tax in line2:        

                if line_tax.tipo_afectacion_igv.code in ["10"]: 

                     self.tax_line_ids[0].amount_total=100

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

Hi,

Not getting exact idea about what exactly you are trying to do, from this line of your code,

self.tax_line_ids[0].amount_total=100

It seems, you are trying to assign some value to the first record of the corresponding one2many field, To get the records dynamically , you can iterate the self.tax_line_ids over the for loop .

for tax_line in self.tax_line_ids:

print("tax line", tax line)



Thanks

Ả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
3539
1
thg 7 25
1648
1
thg 8 25
1153
0
thg 5 25
2041
2
thg 4 25
4307