Chapter 6 - Odoo 15 Development Book

Kanban views

Odoo supports several views. such as tree view, form view, list view, kanban view, pivot view, calendar view etc. The kanban view is a kanban board visualization. It displays records as “cards”, also it is a non-editable view.

Lets create a new kanban view:

Create a model book.

class Book(models.Model):
_name = 'book'
  display_name = fields.Char(string='Name', required=True)
  author = fields.Many2one('res.users', 'Author', required=True)
  sl_no = fields.Char('Sl No', required=True)

Created a action for this model

<record id="action_Book" model="ir.actions.act_window">
  <field name="name">Book</field>
  <field name="type">ir.actions.act_window</field>
  <field name="res_model">book</field>
  <field name="view_mode">kanban,tree,form</field>
</record>

This is the kanban view of this model

<record id="book_kanban" model="ir.ui.view">
  <field name="name">book.kanban</field>
  <field name="model">book</field>
  <field name="arch" type="xml">
      <kanban>
          <field name="id"/>
          <field name="display_name"/>
          <field name="author"/>
          <field name="sl_no"/>
          <templates>
              <t t-name="kanban-box">
                  <div t-attf-class="oe_kanban_global_click">
                      <div class="o_kanban_image">
                          <img t-att-src="kanban_image('book', 'image_128', record.id.raw_value)" alt="Book"
                              class="o_image_64_contain"/>
                      </div>
                      <div class="oe_kanban_details">
                          <strong class="o_kanban_record_title">
                          Name: <field name="display_name"/>
                          </strong>
                      <div t-if="record.author.value">
                             Author: <t t-esc="record.author.value"/>
                      </div>
                          <div t-if="record.sl_no.value">
                              Sl no:<t t-esc="record.sl_no.value"/>
                      </div>
                      </div>
                  </div>
              </t>
          </templates>
      </kanban>
  </field>
</record>

List out the fields that are required and need to be displayed in Kanban view and add the required design. The output of above code is

odoo-crm

The root element of the Kanban view is <kanban>, it can use the following attributes:

default_group_by:

whether the Kanban view should be grouped if no grouping is specified via the action or the current search. It should be the name of the field to group by when no grouping is otherwise specified.

kanban default_group_by="state"

odoo-crm

Here it's grouped by states.

quick_create:

This attribute is used for creating records quickly from Kanban view.

default_order:

We can sort the Kanban cards in a particular order. We can order the Kanban cards by their sl no in ascending and descending order.

<kanban default_order="sl_no desc" >

group_create:

group_create is for adding a new column in kanban view. Its default value will be true.

<kanban default_group_by="state" default_order="sl_no desc" group_create="true" on_create="quick_create" >

Add a column will be removed when we give group_create=”false”

odoo-crm

group_delete:

This attribute is used for deleting a Kanban group. The default value of group_delete will be true.

group_edit:

This attribute is used for editing purposes. The default value of group_delete will be true.

archivable

This attribute is used for archiving and unarchiving the group. If an active field is defined on the model.

<kanban default_group_by="state" default_order="sl_no desc" group_create="false" archivable="true" group_delete="true" group_edit="true" on_create="quick_create" >
odoo-crm

records_draggable:

This attribute is used to drag records when Kanban is grouped. Default value is true.

progressbar:

This is used for having the progress bar on the top.

<progressbar field="kanban_state" colors='{"done": "success", "blocked": "danger", "normal": "muted"}'/>
odoo-crm
whatsapp_icon
location

Calicut

Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635

location

Kochi

Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.

location

Bangalore

Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message