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.

2

What is the context attribute inside a field used for?

By
Eduardo BP
on 6/1/15, 6:03 PM 987 views

Hi Odoo developers.

What is the purpouse of using the context attribute inside a field tag in a form view?.

<form>
....
<field name="field_name" context=? .. />
....
</form>

Thanks in advance.

1


  1. for relational fields only, context to pass when fetching possible values

  2. The context of the view that apply to the tree view. Here, a default filter is applied, the filter_see_all filter we created earlier. So we will see all cashiers.

  3. use the context parameter self.context to retrieve the current session.

  4. merged into the view's context when performing the button's Odoo call

  5. https://www.odoo.com/documentation/8.0/reference/views.html

Sorry but I don't understand what you want to say. Any example would be welcomed.

Eduardo BP
on 6/2/15, 9:23 AM
0
Ankit Gauri
On 6/2/15, 1:44 AM

If you want to specify the views to use, you can add a context attribute, and specify a view id for each type of view supported, exactly like the action's view_id attribute:


<field name="order_line" colspan="4" nolabel="1"

context="{'form_view_ref' : 'module.view_id', 'tree_view_ref' : 'model.view_id'}"/>

you can check here :-

https://doc.odoo.com/6.0/developer/2_6_views_events/views/specify_view_to_use/ 

Thank you

Thank you for your answer Ankit, but I'm not sure if this works with Odoo 8. The link you wrote is for OpenERP 6.

Eduardo BP
on 6/2/15, 7:00 AM

check this link https://www.odoo.com/forum/help-1/question/whats-the-context-2236

Ankit Gauri
on 6/2/15, 7:10 AM

I review your link but it doesn't explained how to use context inside a field but inside a button. This is more logical because a button can be linked to a Python method passing the context inside the button tag, but a field tag can not bounded to any method.

Eduardo BP
on 6/2/15, 11:49 AM

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

1 follower(s)

Stats

Asked: 6/1/15, 6:03 PM
Seen: 987 times
Last updated: 6/2/15, 7:43 AM