Odoo Help

Welcome!

This community 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.

0

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

By
wizardz
on 3/16/16, 5:13 AM 431 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,

store=True)

@api.onchange('project')

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)]},

}

@api.onchange('task_id')

def onchange_task_id(self):

if not self.task_id:

return {}

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

1

Ahmed M.Elmubarak

--Ahmed M.Elmubarak--
2988
| 5 3 5
Sudan
--Ahmed M.Elmubarak--


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

Hi,

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}}

wizardz
on 3/16/16, 9:01 AM
0
Damien Bouvy (dbo)
On 3/16/16, 5:12 PM

Hi,


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.

wizardz
on 3/17/16, 3:56 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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