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

Hi,

I want to do an operation when a form is opened, is there any function is working at the time of opening of a form.I have tried with onchange and compute function but i think it will be depend on particular fields.Is there any other options available for the above purpose.

Expecting fast answers

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

Hi peter,

Can you try the following function 

def fields_view_get

Thanks

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

Hi,

You can check the function named view_init. 

In your odoo directory you can find the description of this function from the file odoo->models.py.

@api.model
def view_init(self, fields_list):
""" Override this method to do specific things when a form view is
opened. This method is invoked by :meth:`~default_get`.
"""
pass

Just write/super this function in your required model and you do the required operations in this function

Hope it helps

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

This would be perfect if only it was called when opening an existing record. Currently it is only at creating a new one.

Câu trả lời hay nhất
def read(self, fields=None, load='_classic_read'): 
	res = super(MyModel, self).read(fields=fields, load=load) 
	​//custom code

return res

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 6 24
4209
0
thg 2 25
852
3
thg 11 23
17363
3
thg 11 24
25012
1
thg 4 23
6103