Odoo Help

2

How to auto-change default field value in view?

By
Antanas
on 9/25/13, 3:50 AM 9,270 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--
5161
| 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

Med Said BARA

--Med Said BARA--
2729
| 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.

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?

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

2 follower(s)

Stats

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