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

How it is possible to use .browse method on the model in order to extract data from the database - and in the same time populate data from other table which is in relation with the searched model.

Consider this:
campaign = self.env["test.campaign"].browse(campaignId)

That is going to return the campaign with the proper id which will have (beside others), properties called campaign_templates

campaign.campaing_templates is a list of ids which is pulled from different table (as per definition of the rules in both of the models).

How it is possible to execute .browse method, so campaign.campaign_templates are populated with full objects as well (instead only with ids). Is this possible, or I need to execute second query in order to achieve this? If this is not possible using .browse method, is there any other way to achieve this?

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

We can close this question. Seems that .browse is already doing that properly. I was missing fields.One2many declaration in one of the models definitions.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 4 22
3260
1
thg 7 21
8201
1
thg 4 16
10440
1
thg 4 15
5737
0
thg 3 23
1589