Odoo ERP is a full suite of business plans and operational control and it can be used in various industries.
The views in Odoo can be defined as per an end user’s requirements and how they want their records to be displayed.
Different types of views in Odoo are:
- Activity
- Calendar
- List
- Cohort
- Dashboard
- Form
- Gantt
- Graph
- Kanban
- Map
- Pivot
- Qweb
- Search
In this blog, we will discuss kanban’s views in detail.
In kanban, view records are displayed as cards. In this view, records can be grouped in columns for the visualization of workflow or ungrouped just for displaying records.
Let’s have a look at how to create a simple kanban view in Odoo 14.
The default view structure of a simple kanban view for displaying the contacts records is given below
class ResPartners(models.Model):
_name = 'res.partner'
_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)
We get the Kanban view given below.
Now let’s see the advanced features in a kanban view.
Default_order
Here in the above kanban, we can sort the kanban cards as per our requirements. For example, if there is any date field in the kanban we can order it by ascending or descending order like given below.
<kanban default_order="date_deadline desc">
Group_create
The default value of group_create will be true. When the default value of this attribute is true then the ‘Add a Column’ option will be visible and we can add new columns in the kanban view.
Add a Column option is there in the above image.
<kanban default_group_by="stage_id" class="o_kanban_small_column o_kanban_project_tasks" on_create="quick_create" quick_create_view="project.quick_create_task_form" examples="project" js_class="project_kanban" sample="1">
This is the code when the value of group_create is true. Once we set its value to false as given below the Add a Column option will get removed.
<kanban default_group_by="stage_id" class="o_kanban_small_column o_kanban_project_tasks" on_create="quick_create" quick_create_view="project.quick_create_task_form" group_create="false" examples="project" js_class="project_kanban" sample="1">
default_group_by
This attribute is used for grouping according to a particular field
Let's take an example of grouping by users,
<kanban default_group_by="user_id" class="o_kanban_small_column o_kanban_project_tasks" records_draggable="false" archivable="false" on_create="quick_create" quick_create_view="project.quick_create_task_form" group_create="false" examples="project" js_class="project_kanban" sample="1">
group_delete
In group_delete also the default value will be true. This will show a Delete option as given in the below image which is used for deleting the kanban group. Let's have a look at the view with the group delete option.
We can remove this delete option as given below,
<kanban default_group_by="stage_id" class="o_kanban_small_column o_kanban_project_tasks" records_draggable="false" group_delete='false' archivable="false" on_create="quick_create" quick_create_view="project.quick_create_task_form" examples="project" js_class="project_kanban" sample="1">`
group_edit
Like other attributes we have discussed earlier, the default value of this group_edit will be true.
The code for removing the edit option is given below.
<kanban default_group_by="stage_id" class="o_kanban_small_column o_kanban_project_tasks" records_draggable="false" group_edit='false' archivable="false" on_create="quick_create" quick_create_view="project.quick_create_task_form" examples="project" js_class="project_kanban" sample="1">
Archivable
The default value will be true.
For removing the archive option, we can set its value false like given below.
<kanban default_group_by="stage_id" class="o_kanban_small_column o_kanban_project_tasks" records_draggable="false" group_edit='false' archivable="false" on_create="quick_create" quick_create_view="project.quick_create_task_form" examples="project" js_class="project_kanban" sample="1">
Quick_create
We can use this quick_create for creating tasks without switching to the form view.
<kanban default_group_by="stage_id" class="o_kanban_small_column o_kanban_project_tasks" archivable="false" on_create="quick_create" quick_create_view="project.quick_create_task_form" examples="project" js_class="project_kanban" sample="1">
When we set the attribute as false then a create task form view will be opened when we click on this create button.
Records_draggable
In a kanban view, we can drag the kanban cards into different stages. It’s because the records_draggable attribute is true by default.
Let's take an example of projects. Here we can drag tasks under each project into its different stages.
We can set its value False and then the records dragging option will be disabled.
<kanban default_group_by="stage_id" class="o_kanban_small_column o_kanban_project_tasks" records_draggable="false" archivable="false" on_create="quick_create" quick_create_view="project.quick_create_task_form" examples="project" js_class="project_kanban" sample="1">
Progress bar
This is used to show a progress bar on the top of kanban columns. The three attributes which are used with the progress bar are field, colors, and sum_field.
Field: Progress bar will be displayed according to the value of this field.
colors: We can assign different colors success, warning, danger and muted as value of the fields.
sum_field: This is optional and its used for showing the sum of a particular field in a record.
In the project module we can define progress bar as shown below
<progressbar field="kanban_state" colors='{"done": "success", "blocked": "danger", "normal": "muted"}'/>
kanban_state = fields.Selection([
('normal', 'Grey'),
('done', 'Green'),
('blocked', 'Red')], string='Kanban State',
copy=False, default='normal', required=True)
In the image given above, we can see the progress bar which shows the state of the records.
Let’s see how the sum_field works in the CRM module.
The progress bar in the CRM module is defined as given below.
<progressbar field="activity_state" colors='{"planned": "success", "today": "warning", "overdue": "danger"}' sum_field="expected_revenue" help="This bar allows to filter the opportunities based on scheduled activities."/>
Here we can see that sum_field is the expected revenue.
In the below image the sum_field is to show the expected revenue.
The Advanced Kanban view functionality with the Odoo platform will help with the operation of the various menu operations of the platform for business management.