Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
2906 Lượt xem

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?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Tác giả

Hi Amr,

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

Tác giả

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

Tác giả Câu trả lời hay nhất

A

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 6 24
1732
2
thg 5 24
7837
3
thg 2 23
16394
0
thg 5 22
2124
4
thg 4 18
17769