Se rendre au contenu
Menu
Cette question a été signalée
1 Répondre
5215 Vues

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.

Avatar
Ignorer
Meilleure réponse

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.

Avatar
Ignorer
Auteur

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.

Auteur

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.

Publications associées Réponses Vues Activité
0
mars 15
4085
1
mars 15
3804
1
oct. 24
68902
2
déc. 23
25463
1
oct. 21
9390