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

Hi !

I'm trying to make a Compute field based on another model.

How can i write the Dependencies as my dependant field in another model ?

I'm using the UI and Odoo Studio as you can see here: https://ibb.co/KhFNC1K

The depencie:  self.env['x_contrat'].x_studio_contacts_1  Is not working saying Unknown field "env['x_contrat']

How can I call another field from another model? 


Thanks for your help ! 

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

Thanks, Niyas.

My problem is not the line of code but the Dependencies - I must a dependent field here:
https://ibb.co/KhFNC1K

My compute field is in the model res.partner and it must be computed based on the model x_contrat.
But I'm not able to refer on the model x_contrat.
Is there any way to it ?

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

Hi,

If you are looking to get some data from the model x_contract, you have to modify your code as follows:

domain = [('id', '=, 10)]
self.env['x_contrat'].search(domain, limit=1).x_studio_contacts_1

in the above sample code, i have used search method to access data from the x_contrat model, in the domain you have to pass your search criteria based on the relation ship between your models. Please change the hard coded domain from the above example as per your use case.

Thanks

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 4 24
3034
2
thg 2 24
3298
1
thg 9 23
8031
0
thg 2 24
2348
1
thg 4 20
2513