Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
2901 Tampilan

Hi,


We have created 2 tables. The first table has name as the column. User will fill this table. 

In the second table, I have I want to create a dropdown which takes the data source as all the names from the first table.


Is this possible?

Avatar
Buang
Jawaban Terbai

Yes for that you will use the Many2one relation to link between 2 models in Odoo. Write In your_module/models/models.py.

    class YourFirstModel(models.Model):

       _name = "first.model"

        name =fields.Char()


    class YourSecondModel(models.Model):

       _name = "second.model"

        name = fields.Char()

        options = fields.Many2one("first.model")



 Read more about how to build a relation in Odoo Docs here.


Happy to help :) an upvote will be awesome

Avatar
Buang
Penulis

Hi Amr,

Thanks for the quick response. Can we do this without saving the first table?

Penulis

Hi Amr,

Thanks for the quick response. Can we do this without saving the first table to database?

@Praveen Lobo

For all the dynamic drop down menus you have to build a table in the database thier is no other option and it's the best practice in odoo. For static menus you can use the Selection field

Penulis Jawaban Terbai

A

Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
2
Jun 24
1730
2
Mei 24
7831
3
Feb 23
16366
0
Mei 22
2116
4
Apr 18
17769