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

Is there a way to call predefined XML in a view? For example, I have a layout group that I want to use in several views and it would be nice to only have to define it once.

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

You can create a view for an AbstractModel model that represents the common features of your models and inherit that view as a template for each model. You don't need to actually inherit the model itself.

View inheritance does not change the inherited view when the target model is different; it is applied on on the target model. You can have one view per model because all inherited views will be applied for each model regardless the view_id defined in action.

A similar concept is used in stock module in v7. The models stock.picking.out and stock.picking.out are created as prototype inheritance of stock.picking (but all models are sharing the same database table using _table = "stock_picking"). New views are created by inheriting from stock.picking views.

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

Mohammad - thanks for the response. I'm not sure I quite understand how to apply this; I am hoping to add these "templates" to existing views (Lead, Opportunity, Customer, etc) without changing any base views. Does this method work with those needs?

Yes. The key point is that inheriting view creates a new view instead of modifying the base view if the base model is different from the inherited view model.

Tác giả

I'm not able to fully understand how I would go about implementing this on existing models; I'll keep playing but if you have any more examples you can outline I'd appreciate it. The stock.picking example is not straightforward to me because the objects seem to be designed around this method, not modified after the fact.

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 3 15
4084
1
thg 3 15
3804
1
thg 10 24
68895
2
thg 12 23
25459
1
thg 10 21
9386