コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
2885 ビュー

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?

アバター
破棄
最善の回答

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

アバター
破棄
著作者

Hi Amr,

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

著作者

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

著作者 最善の回答

A

アバター
破棄
関連投稿 返信 ビュー 活動
2
6月 24
1706
2
5月 24
7807
3
2月 23
16332
0
5月 22
2100
4
4月 18
17755