Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
10243 มุมมอง

Hi all:

I am using the Project App and want to be able to set a default filter view that changes depending on which project is clicked. Instead of having just one project in my default filter view, I want the project I clicked plus another constant project. Ideally I would pass the active_id value of my filter to get something like:

<filter name="my_filter" domain=[('project_id', 'in', ['Constant Project', active_id])] />

However, the active_id field is not available for the search view where I need to define my filter to allow setting it as a default in my context value.

Any help is greatly appreciated, thank you!


อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

You can create object button which will call the method. Inside the button method,  return the action with a custom domain like this.
    

@api.multi
def button_my_filter(self):
return {
'name': self.name,
'view_mode': 'tree,form',
'res_model': 'project.task',
'type': 'ir.actions.act_window',
'domain': [('project_id', 'in', ['ID of Constant Project', active_id])] ,
}

The only problem with this approach is user won't see any filter in the search view.
So the user can't remove it.

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

Thank you! Note that I just changed the domain under the Edit Action item instead of creating a new button. Thanks!

อวตาร
ละทิ้ง

Can you please explain how did you done this?

ผู้เขียน

In debug mode you will see a bug icon in the upper right. If you click on that and click "edit action" you will be able to edit the domain for the screen you are on. You can add your domain code there.

Related Posts ตอบกลับ มุมมอง กิจกรรม
0
ม.ค. 17
3336
5
ก.ย. 20
12856
Help me write this domain and context. แก้ไขแล้ว
1
พ.ย. 24
4939
2
มี.ค. 15
7587
1
มี.ค. 15
5343