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

Hello,

I want to add a filter to the field invoice_lines on the invoice -view. Because the invoices are way to long so I only want to show the sections.

I tried to add a domain directly to the field in the view xml. This doesn't work, the field still shows all the lines. 

I tried to add an extra field: filtered_invoice_lines using the same ID as the invoice lines. I added a domain to this field. 

This works perfect, the field only shows the records I want to. But now there is a problem when I try to create a new invoice. Odoo gives an error, because for some reason this new-field makes it so the bookings are not valid anymore...

Therefor my question: What is the correct way to add a domain filter to a one2many field, so only the wanted records are shown in a view. 

Thank you for your help!

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

Hello Dries Cox
You need to add a domain in .py file

for example=> move_line_nosuggest_ids = fields.One2many('stock.move.line', 'move_id', domain=['|', ('product_qty', '=', 0.0), ('qty_done', '!=', 0.0)])

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

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

Hello Jainesh Shah, Like I explained in my question, I already tried this. This works perfect, but when you do this, it generates a problem when you try to make a new invoice. for some reason odoo adds the lines twice to the booking resulting in an error booking.
If you know a way to make this work without the errors in when making the invoice this would be great. But like this, it doesn't work.

Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 7 15
33181
1
thg 9 23
2468
1
thg 6 22
13446
1
thg 4 21
9787
0
thg 12 16
5374