Here, by reports I mean to combine more than one table to give user some useful information.

One way of doing it is to put related field in an object to replicate other object’s data. For eg., if I want to show sale.order Reference No. and Order Date fields in sale.order.line object, then I can make 2 related fields in sale.order.line to capture the data. But this will unnecessarily increase your DB size. So, a better option is to use views.

Views is same as what we define at database level.  Apart from providing summary information, views can be used to show data of 2 or more tables in one screen. Now, lets see how we can do this in OpenERP-

Step 1- Creating a class

Create a class with _auto=False. This ensures PostgreSQL table is not generated.

Step 2- Defining columns

Column names should be same as what we will define in views.

Step 3- Providing View definition

In def init(), we need to provide view definition such that the select clause has field names which exactly matches the name defined in _columns.

For sample, check addons/sale/report/sale_report.py.

Advertisements