How I can change the default value of a field in a form view in openerp7?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
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--
2--
3--
4--
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)]:
Hope this can help, and best regards.
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
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 :)
Dude I know this answer is 6 years old, but you saved my a** and I owe you a beer :)