Odoo Help

0

[V8] Change view based on current model

By
Aurélien Rivet
on 3/21/16, 5:18 AM 299 views

Hi,

I want to use one wizard to act on multiple models. Depending on the model the wizard acts on, some fields of the form view have to change. Currently, I have created two views and choose the one I would like to use using the view_id attributes on the action associated to each model. But I have to create two views and this is not very "DRY". Is there any way to get the current model from xml and make some part of the form view visible/invisible depending on it ?

0

Ahmed M.Elmubarak

--Ahmed M.Elmubarak--
3168
| 5 3 5
Sudan
--Ahmed M.Elmubarak--


Ahmed M.Elmubarak
On 3/21/16, 7:56 AM

Hello,

You can use the action's context to achieve that ...

e.g:

if you've two models model-1 and model-2, you can create two boolean fields [this is just to illustrate the idea] model1, and model2

make them invisible in the wizard's form.

then in your action [e.g for the first model] define the context as :

<field name="context">{'default_model1':1}</field>


And in the wizard's form make your fields invisible depends on that e.g:

<field name="field1" attrs="{'invisible': [('model1', '!=', True)]}"/>


Hope this will help



Hi and thanks for your response. Yeah it seems to be the right way to do it.

Aurélien Rivet
on 3/21/16, 8:39 AM

About This Community

This platform 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.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 3/21/16, 5:18 AM
Seen: 299 times
Last updated: 3/21/16, 8:39 AM