Odoo Help


How Can I make a function that doesn't shows me my task that are finished?

on 3/16/16, 5:13 AM 921 views

I have this code. I need a function that filters all Tasks out that are in stage == "finished" . How Can I make that?

When the task is in stage finished it should't show up in the selector of all tasks.

This function shows me all tasks from a project and again all tasks that are in stage_id == finished

How Can I make that so, that all "finished" tasks are not showing in this selector include_in_task_work_view???

class ProjectWork(models.Model):

_inherit = 'project.task.work'

project = fields.Many2one(

string='Project', related='task_id.project_id', store=True,

domain="[('state', 'not in', ('template', 'cancelled', 'close'))]")

include_in_task_work_view = fields.Boolean(

related='task_id.stage_id.include_in_task_work_view', readonly=True,



def onchange_project(self):

if not self.project:

return {'domain': {'task_id': []}}

return {

'domain': {

'task_id': [('project_id', '=', self.project.id),

('include_in_task_work_view', '=', True)]},



def onchange_task_id(self):

if not self.task_id:

return {}

return {'value': {'project': self.task_id.project_id.id}}

--Ahmed M.Elmubarak--

Ahmed M.Elmubarak
On 3/16/16, 8:37 AM


I didn't get the question very well, But you get the ids of the records not in finished state by using the search method:

not_finished_ids = self.search([('state', '!=', 'finished')]) ...

Hope this could help

I want a function that search all tasks that are not finished and that they display on this : @api.onchange('task_id') def onchange_task_id(self): if not self.task_id: return {} return {'value': {'project': self.task_id.project_id.id}}

on 3/16/16, 9:01 AM

Damien Bouvy (dbo)

--Damien Bouvy (dbo)--

| 1 0 1
Grand-Rosière, Belgium
--Damien Bouvy (dbo)--

Damien is part of the Odoo R&D department. He has taken part in the development of several features in Odoo, including the Subscription application, the Sales application, the frontend portal and the payment acquirers.

Nowadays he commits on our internal codebase, maintaining the billing process of Odoo.com, developing external tools and internal processes. More recently, he took part in the development of the Odoo.sh platform.

Damien Bouvy (dbo)
On 3/16/16, 5:12 PM


I honestly don't really get the question as well.

If what you want is to hide tasks from task selectors (many2one fields on other objects that link to a task), you could use the "active" field on tasks. The active field is used by the ORM/web client to hide things from list views, selectors, etc. automatically.

I want to hide all tasks that are in stage "finished" . I have this modul. https://www.odoo.com/apps/modules/8.0/project_work_time_control/ The Problem is , that the selector (field that shows all tasks) is not filtering the task. So all finished tasks are showed up. I want to hide all finished-tasks.

on 3/17/16, 3:56 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 3/16/16, 5:13 AM
Seen: 921 times
Last updated: 3/23/16, 5:22 AM