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.

0

How to use the button attribute "args"

By
Nikhil Mohan
on 10/12/16, 5:07 AM 281 views

https://www.odoo.com/documentation/9.0/reference/views.html

In the above documentation we can see there is an attribute named "args" associated with button elements. But the document lacks more details about using this attribute. Instead it just says "see type". I tried to find the usage of this attribute by checking Odoo's core modules, but ends with no result.

  1. Is it something we can use to pass the data from view file to python code?

  2. What is the syntax? (key/value dict)

  3. How to get access the passed data in Python?

  4. What is the difference with args and context?

Any help would be appreciable!


0

Bejaoui Souheil

--Bejaoui Souheil--
808
| 2 1 4
Sousse, Tunisia
--Bejaoui Souheil--

Odoo developer,  functional and technical consultant

souheil_bejaoui@hotmail.fr

Bejaoui Souheil
On 10/12/16, 12:51 PM

Hi,

Context

Context is a dictionary carrying session data. Context can be used in the server or the client side. In your view you can add new values like this:

<button name="apply" context="{'key': value}" />

and get this value in the server side like this:

value = self.env.context.get('key')

attrs

attrs is a dictionary carrying some field option like invisible, required and readonly. attrs allow you to define condition for each option like this:

  <field name="name" attrs="{'invisible': [('condition', '=', True)]}">

The field name will be invisible if condition is true.

Best regards.

@Bejaoui Thanks for your help! But I was asking about "args" not "attrs".

Nikhil Mohan
on 10/13/16, 12:08 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: 10/12/16, 5:07 AM
Seen: 281 times
Last updated: 10/12/16, 12:51 PM