Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
4 Odpowiedzi
10561 Widoki

Hello!


I have a many2many relationship in a model. In a tree view, I just want to show an specific field of this many2many relationship, not the id. Is it possible to do it from the online version using the Settings > Technical > View or Model? Or how can I do it?


Example: Imagine I have a patient model and a doctor model. And in the tree view of Patient I want to show the name of the doctor associated to this patient, not the id of the doctor. How can I do it?


Thank you in advance

Awatar
Odrzuć
Autor

Unfortunately, it doesn't help... I can't get what I want. Is there any other way?Is it imposible to do it?

Najlepsza odpowiedź

Hello Marta,

Please define your many2many field in the tree view with the widget "many2many_tags".

Here is the example of field many2many field tag_ids which defined in the tree view:

 <field name="tag_ids" widget="many2many_tags"/>

Thanks

Regards,




Email:      odoo@aktivsoftware.com  

Skype: kalpeshmaheshwari

   

Awatar
Odrzuć
Najlepsza odpowiedź

Hi @MartaLeal, in this case, you need to change the display name in your model, probably for this reason the field is displaying the ID instead of name.

Use something like this in your doctor model:

class ResDoctoc(models.Model):
​_inherit = 'res.doctor'
​_res_name = 'doc_name' # here you put your model name.

​doc_name = fields.Char()

I hope it helps someone!

Awatar
Odrzuć
Autor Najlepsza odpowiedź

Hello both!

None of them worked. It still displays the id (I suppose it is the key of the relationship). I'm not sure if I had not explained it clearly. Going back to the example, where I want to see the name of the doctor is in the tree view of the menu, not inside the model. I need to see it at a first glance, not by entering to the record and then checking who is the doctor.

What I need is this:

PatientDatePhoneEmailDoctor
ABCdd/mm/yyyy123456789aa@example.esDEF ghi
However, what I'm getting right now is Doctor: 0001 (for instance). I don't want the number, I want the name. 

Awatar
Odrzuć
Najlepsza odpowiedź

if you want to see only name you can use <field name="field_name" widget="many2many_tags"/>

if you want to show other detail then use bellow

<field name="field_name" nolabel="1">

                                    <tree editable="bottom">

                                        <field name="name"/>

                                        <field name="email"/>
                                        <field name="number"/>

                                    </tree>

                                </field>

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
kwi 16
3569
3
kwi 23
53725
0
cze 24
888
0
maj 22
1051
0
paź 21
5878