Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
19682 Vizualizări

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

Imagine profil
Abandonează
Cel mai bun răspuns

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.

Imagine profil
Abandonează

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

Cel mai bun răspuns

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 :)

 

Imagine profil
Abandonează

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

Related Posts Răspunsuri Vizualizări Activitate
0
feb. 23
3071
1
mar. 15
4463
3
iun. 25
652
6
apr. 22
42872
0
mar. 24
3905