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

How to auto-change default field value in view?

By
Antanas
on 9/25/13, 3:50 AM 8,111 views

Hi,

When there is a default value for a field in model, f.e.

class Foo(orm.Model):
    _name = 'foo.bar'
    _columns = {
        'bar': fields.boolean('Bar'),
    }
    _defaults = {
        'bar': False,
    }

I would like ths default value to be changed to True in one of form views of the model. Is it possible to automatically change default 'bar' value in view, by use of some field attribute etc., without user input?

5

Andreas Brueckl

--Andreas Brueckl--
5056
| 7 8 7
Vienna, Austria
--Andreas Brueckl--
OpenERP Consulting and Development
Andreas Brueckl
On 9/25/13, 5:47 AM

You can do this in the context of the Window Action.

Just write {'default_bar': True} in the context.

Guys I can't get your solution to work here at all. I have a boolean field 'is_repair', and I have been trying to use context 'default_is_repair': True, but it isn't working. Can you help me here?

David
on 12/18/13, 9:52 PM
2
DM
On 5/22/15, 12:27 PM

if you want to default boolean you can use 1=True, 0 False

in your python file

_defaults {

'default_is_repair': 1

}

0
David
On 12/18/13, 9:42 PM

Guys I can't get your solution to work here at all. I have a boolean field 'is_repair', and I have been trying to use context 'default_is_repair': True, but it isn't working. Can you help me here?

0

Med Said BARA

--Med Said BARA--
2664
| 5 5 7
Algeria
--Med Said BARA--
Med Said BARA
On 2/16/14, 6:28 PM

Activate "Developper Mode", Open the form you want, under the drop-down menu "Debug View" you will find "Set Default" ....... Choose the value you want.

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

2 follower(s)

Stats

Asked: 9/25/13, 3:50 AM
Seen: 8111 times
Last updated: 6/15/15, 10:09 AM