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

Hi all,

 Am working on petrol pump management system and I would like anyone to tell me how to retrieve the value of one field to another,

In my module I have one field called x_unitprice which is the price of one litre fuel, however I want to get this value in my form automatically once I choose the product name (fuel_product_id)

Kindly tell me the detail of the same with the following in the front end

datatype, Related field, dependencies, compute

Ảnh đại diện
Huỷ bỏ

Hi,

It seems you are doing everything from the ui itself, nice if you try to do the same from the code because later if you need to change the db or db get corrupted in case means you will loose everything... also doing it from the ui wont give you much flexibility, if you are new to coding, check this: https://www.youtube.com/watch?v=BDepk0LhVuI&list=PLqRRLx0cl0hoJhjFWkFYowveq2Zn55dhM

Câu trả lời hay nhất

Make onchange function for  fuel_product_id  

@api.onchange('fuel_product_id')
def onchange_fuel_product_id(self):
    self.x_unitprice = self.fuel_product_id.field_name_you_need_value

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

Mohammed Anees, Thank you for your answer but I want this in front end during making fields

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 8 22
2422
0
thg 9 18
3170
1
thg 8 24
8144
1
thg 9 23
7716
3
thg 10 21
9559