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

Hi! 

I have created a model called "Cars", which contains a field many2one based on the Contact (car's owner).


In my Contact form, I've added my Cars model as a m2m field (a contact can have multiple cars). I want to filter my cars based on the Owner's. 


Presently, I see all cars, but I want to see only the cars where the Owner is the contact.

How can I do that?


Thanks!

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

Hi,


Here's an example of how you can achieve this in your Contact form view:

       

  1.        

    Open the XML file where you have defined the Contact form view (usually in the views folder of your module).

       

  2.    

  3.        

    Find the Many2many field for Cars in the Contact form view. It should look something like this:

       

   

       

<field name="cars" widget="many2many_tags" domain="[('owner', '=', active_id)]"/>

   


Hope it helps

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

Thank you very much! It worked!!

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

.This is fairly easy to do in Studio, but cannot be done directly in the UI.  You can see my previous answer here

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
มี.ค. 23
3205
1
ก.พ. 24
2191
filter_partner not working แก้ไขแล้ว
1
ก.ย. 23
1359
0
ก.ค. 24
3267
0
ก.ค. 22
60