Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
3 Risposte
1517 Visualizzazioni

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!

Avatar
Abbandona
Risposta migliore

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

Avatar
Abbandona
Autore Risposta migliore

Thank you very much! It worked!!

Avatar
Abbandona
Risposta migliore

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

Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
2
mar 23
3153
1
feb 24
2112
1
set 23
1318
0
lug 24
3155
0
lug 22
60