01 luglio 2015

How to add a new field to odoo view through web interface

And avoid it to be removed while updating modules

Agile Business Group Sagl, Lorenzo Battistini
Sometimes you need to add a simple field to odoo views but you don't want to develop a new module just for that.

The following steps describe the basic case about how to add a textual field to an odoo view. In this way you are also sure that you will not loose your changes when in future will update odoo modules.
  1. Activate developer mode
  2. Go to Configuration -> technical -> Database structure -> Models
  3. Open for example account.invoice
  4. Add a textual field x_test
  5. Go to invoices list
  6. From debug menu click on manage views
  7. Click on edit
  8. Click on the field where you want to add the new field (e.g. state)
  9. Click on inherited view
  10. Select the new node (state) and click on '+'
  11. Select x_test
  12. Update
  13. Close

Obviously, this method can't cover every possible use case and you often will need to develop a module, but it can help in some simple cases

Note

Alternatively, you could use the Non Updatable on the ir.model.data record of the main view, modifying it directly and avoiding to create an inherited view. But this will prevent future updates (possibly bugfixes) for the main view to be applied. Instead, using inherited view, the main view will be able to receive bugfixes and your view will just extend it.