how-to-create-simple-kanban-view-odoo-12.png
Blogger_637003162157024481.png
By: Vinaya Suresh

How to Create a Simple Kanban View in Odoo?

Odoo is considered as the world’s easiest business management software for the efficient management of business departments. The open-source ERP comes integrated with several management modules such as CRM, Sales, Purchase, Human Resource, Accounting, Point of Sale and many more for streamlining major share of business operations.


As the majority have seen and experienced, data in Odoo programs are stored as objects and these objects are represented using Odoo views. Odoo supports several views such as tree view, list view, kanban view, cohort view, pivot view, calendar view offering different styles of data representation. This in and around helps the businesses in large, offering complete visibility of their operations, thereby smarter business decisions.



Here in this blog, I'm going to discuss how to create a simple kanban view in Odoo.


Kanban view:

The kanban view displays the records halfway between a list view and a non-editable form view. 


how-to-create-simple-kanban-view-odoo-12


Let’s see how to make a simple kanban view:


Specify the view mode as kanban in the record. The main element in the kanban view is <kanban>.


Create a new model eg: res.partners


class ResPartners(models.Model):
_name = 'res.partners'
_description = 'Partners'
_rec_name = 'display_name'
display_name = fields.Char(string='Name', required=True)
email = fields.Char('Email', required=True)
mobile = fields.Char('Mobile', required=True)


Define the XML view as shown below:


<record id="action_contacts_summary" model="ir.actions.act_window">
        <field name="name">Contacts</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">res.partners</field>
        <field name="view_type">form</field>
        <field name="view_mode">kanban,tree,form</field>
        <field name="search_view_id" ref="base.view_res_partner_filter"/>
        <field name="help" type="html">
            <p class="o_view_nocontent_smiling_face">
                Create a contact in your address book
            </p>
        </field>
    </record>
<record id="partner_kanban_view" model="ir.ui.view">
            <field name="name">res.partner.kanban</field>
            <field name="model">res.partners</field>
            <field name="arch" type="xml">
                <kanban class="o_res_partner_kanban">
                    <field name="id"/>
                    <field name="display_name"/>
        <field name="email"/>
                    <field name="mobile"/>
                    <templates>
                        <t t-name="kanban-box">
                            <div t-attf-class="oe_kanban_global_click">
                                <div class="o_kanban_image">
                                    <img alt="Avatar" t-att-src="kanban_image('res.partners', 'image_medium',record.id.raw_value)"/>
                                </div>
                                <div class="oe_kanban_details">
                                    <strong class="o_kanban_record_title">
                                    <field name="display_name"/>
                                    </strong>
                                <div t-if="record.mobile.value">
                                        <t t-esc="record.mobile.value"/>
                                </div>
                                    <div t-if="record.email.value">
                                        <t t-esc="record.email.value"/>
                                </div>
                                </div>
                            </div>
                        </t>
                    </templates>
                </kanban>
            </field>
        </record>


List out the fields that needed to be displayed in kanban view and add the required design.


The output of the above code is shown below:


how-to-create-simple-kanban-view-odoo-12


Templates:

It is the list of qweb templates. The kanban views must define one root template kanban-box.


Record:

The attributes of record are the requested fields. The field has two attributes value and raw_value. The value is formatted based on the user’s parameter, raw_value is the value from the read() function.


Field:

The field to be displayed in the kanban view.

Following attributes can be used with the root element <kanban>:


default_group_by:

It specifies whether the kanban view should be grouped if no group is mentioned.


Example: <kanban default_group_by="field_name">


default_order:

The default sorting order of records.


Example: <kanban default_order="field_name">


Class:

The class adds the HTML classes to the root element.


Example: <kanban class="class_name">


group_create:

Specifies whether the ‘Add a new column’ bar is to be displayed or not. The default value of group_create is true. 


Example: <kanban group_create="false">


group_delete:

Specifies whether the groups can be deleted or not, the default value is true.


group_edit:

Specifies whether the group can be edited or not, the default value is true.


archivable:

Specifies whether the records can be achieved or not followed by the field, active should be defined in the model.


Example: <kanban class="o_kanban_mobile" archivable="false">


quick_create:

Specifies whether the records can be created from the kanban view or not.


Example: <kanban quick_create="false">.





Comments

0


Leave a comment

 
Calicut

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

London

Cybrosys Limited
Alpha House,
100 Borough High Street, London,
SE1 1LB, United Kingdom

Kochi

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

Bangalore

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

Send Us A Message