İçereği Atla
Menü
Bu soru işaretlendi
2 Cevaplar
19700 Görünümler

How I can change the default value of a field in a form view in openerp7?

Avatar
Vazgeç
En İyi Yanıt

Hi; The simplest and easiest way , is to go under "Developer mode", and then open the form (you want), open the drop-down menu "Debug view" and choose "Set Defaults", modify the default values as you need.

steps to go under "Developer mode" and change default values (example of "Emplyee form"):

1-- image description

2-- image description

3-- image description

4-- image description

The more complexe way is to find the file where the field you want to change the default value is defined (created) [Probably in a class a_class definition after _columns = {.......} creation in _defaults = {..somewhere...here ..the default value....} statement, as in the example below ( extracted from the code mrp.py file of the mrp module)]:

image description

Hope this can help, and best regards.

Avatar
Vazgeç

Excelent answer! Thank's for taking your time answering with graphical examples. I'm very grateful for your answer.

If you need to change a lot of defaults (as the defaults set from Developer's Mode is per user), you can check this answer: https://www.odoo.com/forum/help-1/question/how-to-change-default-journal-when-i-create-a-new-customer-invoice-74128#answer_74130

En İyi Yanıt

If you want to change the default value to something that is not listed in the Default dropdown, then you should do the following (it's way faster and there's no need to change the code):

Fill the field with wanted value which you want to set to default and THEN go to the developer mode, Click on Debug View dropdown and select Set Defaults. Now you see you have a NEW (exactly the one you wanted) default value in the dropdown, which you can select.

It can't get any easier than that :)

 

Avatar
Vazgeç

Dude I know this answer is 6 years old, but you saved my a** and I owe you a beer :)

İlgili Gönderiler Cevaplar Görünümler Aktivite
0
Şub 23
3077
1
Mar 15
4465
3
Haz 25
667
6
Nis 22
42893
0
Mar 24
3912