Why are all inheriting views applied everytime?

Asked by Francois Degrave

Hi!

I created 2 views. A root one, say id=250, and another one, id=251, inheriting from view 250.

When I create an action that explicitely refers to 250, why is view 251 applied? I think it shouldn't. This feature prevents from re-using existing views in differents contexts requiring some modifications of the views.

Question information

Language:
English Edit question
Status:
Answered
For:
Odoo Server (MOVED TO GITHUB) Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Jean-Sebastien SUZANNE - http://www.Syleam.fr (alnjssuza) said :
#1

Hi Francois,

When ORM get a view. He search all inherit view and apply xpath in order of priority.
So your modules can add new field in view without refactoring all the views and actions.

Revision history for this message
Francois Degrave (fde-be) said :
#2

I know, that's not the question. If I WANT to use the original view, without the inherited fields, it is just not possible even if I refer directly to this original view in the action.

That means I cannot reuse a view to adapt it according to a context; I have to rewrite it from scratch.

Revision history for this message
Francois Degrave (fde-be) said :
#3

So well, I still need an answer.

Revision history for this message
Thibaut DIRLIK (Logica) (thibaut-dirlik) said :
#4

Try passing 'tree_view_ref' or 'form_view_ref' in you actions' context.

2011/8/18 Francois Degrave <email address hidden>

> Question #168270 on OpenERP Server changed:
> https://answers.launchpad.net/openobject-server/+question/168270
>
> Status: Answered => Open
>
> Francois Degrave is still having a problem:
> So well, I still need an answer.
>
> --
> You received this question notification because you are a member of
> OpenERP Committers, which is an answer contact for OpenERP Server.
>

Revision history for this message
Francois Degrave (fde-be) said :
#5

Still not that. I know -- I checked in the code -- that fields_view_get creates a view using the "root" view and ALL inheriting views, even if you explicitly referred to the root view in the action.

I think it shouldn't be the case; if you have a tree of inheritance:
   A
  / \
B C

if you explicitly refer to A, you should have A only. If you refer to B, you should have A+B. If you don't refer to a particular view, you should have the whole thing, A+B+C. Don't you think?

Revision history for this message
Numérigraphe (numerigraphe) said :
#6

 I don't think that would make sense in this context.
The purpose of inherited views is to modify the a view in a module without the other modules having to know.
The other modules still call the original view's name (A in your example) but they benefit from the improvements of the other modules.
So don't think of it as an OO inheritance like Java's, that's not what view inheritance is.
If you want an unchanged view, why not do a copy of it ? Since views are recorded as objects, I think it can be done using the ORM.
Lionel Sausin.

Revision history for this message
Francois Degrave (fde-be) said :
#7

Yes, that's what I finally did: redefining the field_view_get in order to customize an existing view by adding buttons myself. But I don't find that really pretty, and I'm quite sure there is a way -- maybe not the one I proposed -- to make the inheritance mechanism much more flexible than it is.

Can you help with this problem?

Provide an answer of your own, or ask Francois Degrave for more information if necessary.

To post a message you must log in.