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

I've got a model (Model_A) that has a One2many relation to his positions model (Model_B). That model (Model_B) has a Many2many related field that I want to filter based on partner_id.

The views are Model_A form view with list for Model_B that is not editable, so it opens a popup view for creating/editing Model_B records. When adding a new record to Model_B in the popup view the filter works, but if I edit the record there is no filter applied on the Many2many field.



The partner_id field is a related field from parent Model_A

partner_id = Many2one(related='Model_A.partner_id')


And I tried even with a non related field. The problem is still there. 

I cannot use any python method to set the domain with onchange because it doesn't depend on anything and on create it works, on edit there will nothing be changed only records added/removed to this Many2many field. 


Does someone know what can be the problem or how to fix the issue?

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

don't know how to post view code that id does not disappear? Even with the /Code option

Tác giả Câu trả lời hay nhất

Just had to write the domain in python code in the field definition. Don't like doing it that way because if you want to add something you cannot just edit the view.

some_field_ids = Many2many(comodel_name='some.model', domain="[('partner_id', '=', partner_id)]")



Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
16
thg 12 23
33048
1
thg 9 23
2399
1
thg 10 24
3314
1
thg 7 22
6153
0
thg 11 22
80