Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

Insert predefined XML into view

By
Allison
on 3/15/13, 10:33 AM 1,371 views

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.

0

Mohammad Alhashash

--Mohammad Alhashash--
2075
| 5 5 8
Giza, Egypt
--Mohammad Alhashash--

Developer

Mohammad Alhashash
On 3/15/13, 5:23 PM

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?

Allison
on 3/19/13, 10:03 AM

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.

Mohammad Alhashash
on 3/19/13, 5:16 PM

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.

Allison
on 3/20/13, 12:04 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 3/15/13, 10:33 AM
Seen: 1371 times
Last updated: 3/16/15, 8:10 AM