March 2018
Beginner to intermediate
336 pages
8h 22m
English
When designing the form structure, we included a top-right area to contain smart buttons. Let's now add a button inside it.
For our app, we will have a button displaying the total number of To-Do tasks for the owner of the current To-Do task, and clicking on it will navigate to the list of those items.
First, we need to add the corresponding computed field to models/todo_task_model.py. Add the following to the TodoTask class:
def _compute_user_todo_count(self):
for task in self:
task.user_todo_count = task.search_count(
[('user_id', '=', task.user_id.id)])
user_todo_count = fields.Integer(
'User To-Do Count',
compute='_compute_user_todo_count')
Next, we add the button box and the button inside it. Right at the top of the
Read now
Unlock full access