We used cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it. What For?

« Back to Blogs

Odoo Grid View

Odoo Grid View
Overview

As we know ODOO is the most popular ERP framework. There are multiple modules to enhance your business and also very user-friendly to manage your business.

All data are displayed in different views dynamically and statically as well. Odoo introduced many views like Form, Tree, Kanban, Pivot, Calendar, and Grid view, etc. But, All these views are not available in the community edition e.g. Grid view.

We have fully implemented a Grid view in the community edition with backend & UI the same as an enterprise edition.

Features
  • Data are displayed based on intervals like Week, Month and Year
  • Easily create a record from the wizard
  • To Navigate all records interval wises
  • Ability to open a particular cell record using the search icon
  • Easily modify the cell value as per user’s need using cell editable property
  • Ability to filter the data using Odoo’s default filtration
  • Very user-friendly interface and management
Grid View

Odoo has introduced the Grid view, especially in the Timesheet module to manage data. It is providing a very user-friendly UI from the Project-Manager side and from the Employee side as well.

In this blog, we will understand how to define the Grid view in XML. If you need the whole source code of the grid in your community edition then please contact us.

In the Grid view, data are displayed dynamically through a month or week wise as per the below image.

Odoo Grid View
There are multiple buttons as listed below:
  • Add a Line: Used to create a new record from the opening wizard of a current object.
  • Week: To display data week-wise.
  • Month: To display data month-wise.
  • Today: To render data of the current date.
  • Arrows: To navigate the next or previous data.
Declaration

So, let's start defining a grid view in the timesheet module. You can define it in the XML as per the below code.

Odoo action renders all the views such as grid, pivot, tree, etc. So first, we need to inherit the action to add the grid view.

Window Action:

<record id="hr_timesheet.timesheet_action_all" model="ir.actions.act_window">
   <field name="name">All Timesheets</field>
   <field name="res_model">account.analytic.line</field>
   <field name="view_mode">grid, pivot, tree</field>
   <field name="context">{'search_default_groupby_employee': 1, 'search_default_groupby_project': 1}</field>
</record>

 

view_mode: Renders all defined views on Odoo for particular models.

View Mode in Odoo

After passing action need to create a gird view as per below:

<record id="timesheet_view_grid_by_project" model="ir.ui.view">
   <field name="name">account.analytic.line.grid.project</field>
   <field name="model">account.analytic.line</field>
   <field name="arch" type="xml">
       <grid string="Timesheets" adjustment="object" adjust_name="adjust_grid">
           <field name="project_id" type="row" section="1"/>
           <field name="task_id" type="row"/>
           <field name="date" type="col">
               <range name="week" string="Week" span="week" step="day"/>
               <range name="month" string="Month" span="month" step="day"/>
           </field>
           <field name="unit_amount" type="measure" widget="timesheet_uom"/>
       </grid>
   </field>
</record>

string: The title of view.
adjustment: Indicate current model object.
adjust_name: Method to perform CRUD operation in backend.
type:

  • row: Display records (group) row-wise
  • col: Display records (group) column-wise
  • measure: Measure the group’s data on float value or time etc.

range: week (All records will display week wise)

Get Data in Weekly Format

range: month (records will display month wise)

Odoo Grid View

Users can also use some more optional parameters to enhance functionality on the grid view like to create, edit, and delete, etc.

These all parameters have true or false values. By default it is true.

<grid string="Timesheets" adjustment="object" adjust_name="adjust_grid" create="false" edit="false">

If a user modifies values in a grid tag like, create = false and edit = false as above code, then the user should not be able to create or edit a record from the grid view.

Users are also able to use other optional parameters like on_change, can_create, modifiers, and can_write in the fields to make some operations like other views. So, these configurations are enough to define the grid view in XML.

To get the whole workable source code, you can contact us.

contact-us Request a callback WhatsApp