Odoo 12 Development Essentials
上QQ阅读APP看书,第一时间看更新

The view layer

The view layer describes the user interface. Views are defined using XML, which is used by the web client framework to generate data-aware HTML views.

We have menu items that can activate actions that can render views. For example, the Users menu item processes an action also called Users, which in turn renders a series of views. There are several view types available, such as the list (sometimes called tree for historical reasons) and form views, and the filter options made available in the top-right search box are also defined by a particular type of view, the search view.

The Odoo development guidelines state that the XML files defining the user interface should be placed inside a views/ subdirectory.

Let's start creating the user interface for our to-do application.

In the next sections, we will make gradual improvements and frequent module upgrades to make those changes available. You might also want to try the --dev=all server option, which spares us from module upgrades while developing. Using it, the view definitions are read directly from the XML files so that your changes are immediately available to Odoo without the need for a module upgrade.

If an upgrade fails because of an XML error, don't panic! Read the error message in the server log carefully; it should point you to where the problem is. If you feel in trouble, just comment out the last edited XML portions or remove the XML file from  __manifest__.py and repeat the upgrade. The server should start correctly.