Skip to content

Views Configuration En

Project Views Configuration

Apart from the generic list and report views for projects and tasks, ERPNext also provides Gantt, Kanban, and Calendar views for tasks. You can access these views by going to the Task list and selecting them via the right sidebar.

Kanban Button

In ERPNext there is a Kanban view that have a different way to show the tasks of some project.

We can go to the Kanban View using the View button in the upper right corner of the Project doctype.

view_button

But what if we want the button that move us to the Kanban View on the spot.

To do the Kanban Button we need to:

  1. Go to the Client Script doctype

  2. Press the Add Client Script button

  3. Name your script

  4. Select the doctype where this button will be located (In our case it’s ‘Project’)

  5. In the Script form write down this code:

    frappe.ui.form.on('Project', {
    set_custom_buttons: function(frm) {
    frm.add_custom_button(__("Kanban Board"), () => {
    frappe.call('erpnext.projects.doctype.project.project.create_kanban_board_if_not_exists', {
    project: frm.doc.name
    }).then(() => {
    frappe.set_route('List', 'Task', 'Kanban', frm.doc.project_name);
    });
    });
    }
    })
    • We use frappe.ui.form.on to indicate the Doctype where the client script will work
    • We use frm.add_custom_button to give a name the button and indicate the function that will work after the button is pressed
    • in the frappe.call we reffer to the create_kanban_board_if_not_exists that creates the Kanban Board attached to current project if board do not exists yet
    • frappe.set_route function is used for redirecting to a new route (in our case it’s ‘List’, ‘Task’, ‘Kanban’, frm.doc.project_name - returns the current project name)
  6. Turn on the Enabled option

  7. Press the Save button

client_script

After this the button will appear in the Project doctype

project_button

This button will redirect us to the Kanban View filtered by project name

kanban_board

Calendar View for Doctype

In ERPNext some doctypes have a build in calendar view. You can set the calendar view in needed doctype by creating a configuration file in the Frappe file system. The configuration file should be named {doctype}_calendar.js and should exist in the doctype directory.

Here is an example configuration file for calendar view for Appraisal doctype, which must be set in the appraisal_calendar.js file.

frappe.views.calendar["Appraisal"] = {
field_map: {
start: "start_date",
end: "end_date",
id: "name",
title: "employee_name",
},
}
  • frappe.views.calendar provides functionality for displaying data in a calendar view
  • field_map key is an optional configuration parameter that can be passed to the frappe.views.calendar module in order to specify how event data should be mapped to the fields in the calendar view
  • start - specifies the field in the document that contains the start date and time of the event.
  • end - specifies the field in the document that contains the end date and time of the event.
  • id - specifies the field in the document that contains the unique ID of the event.
  • title - specifies the field in the document that contains the title of the event.

After this go to the needed doctype and press the Customize option. In the Customize Form turn on the Is Calendar and Gantt option.

is_calendar

Now if you press the Views button in the doctype you’ll se the Calendar view.

calendar_view