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.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
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.
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.
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.