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

Hello,

I try to inherit the existing model, define some new fields and redefine the state of the default model also, but i do not want this new fields affect the default model (keeping the behaviour of the default model).

Is it possible to achieve that (besides copy the default model)?  

---------------------------------------------

Problem solved:

Use 'ir.action.act_window.view' in the action view definition and utilize a method named 'fields_view_get', you can override this method to modify the view that inherit another view without change/affect the default view.


Thanks

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

Hi yopi, I just encounter a similar problem. Can you explain in details on how to do it? especially the method you mentioned. Thanks a lot!

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

Hello Ivan,

Thanks for the quick response :).

Besides of copy the default model, is there another way to achieve that?

I inherit a sale.order model, and redefine the state fields. When i load/open the web, this model is already updated with the new state. (what i mean is the default state of sale.order model is not affect by the inherit model -- is it possible?) 

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

The way provided are either you copy the entire thing (prototyping), use delegation (which may make use harder to customize the parent model), or use the normal inheritance. If you need something else, you would need to develop your own inheritance mechanism.

Tác giả

Thanks Ivan, it seems i need extra work to achieve it. :)

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

Check out this documentation page on inheritence. There are various ways to inherit an object, depending on how do you want to "use" the field in the other class from the new class, that is provided by OpenERP.

For your purpose, maybe inheritance by prototyping is the most appropriate.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 9 16
4528
1
thg 3 15
6645
1
thg 5 23
2462
3
thg 3 15
9667
1
thg 11 24
1695