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

I want to access data from foreign models via foreign-key from inside .xml-views.

Concrete example: account.invoice.tree

account.invoice model "knows" partner_id as foreign key. I also want to display res.partner.cust_id inside account.invoice.tree. From inside .rml reports, I can simply do o.partner_id.cust_id and the field desired is displayed without needing to inherit the appropriate python class. Can this be achieved like that from within .xml view files and if yes, how?

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

A view can only display data from a single model.

You can create a new model, which combines information from two others, and is defined by a SQL statement.

See https://accounts.openerp.com/forum/Help-1/question/12350

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

Thank you very much! I will try that. I had another idea: Inherit account.invoice model and add a function field for every additional field from foreign model I need. These fields could have store="False" property, as their values are already available and needn't be entered/stored. Would this approach work, too?

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 4 22
18364
0
thg 1 22
2838
3
thg 12 23
6025
0
thg 12 22
2850
0
thg 7 20
4052