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.

2

Create a "domain" so that only the Project's Team can be assigned to a Task

By
Daniel Reis
on 8/28/13, 1:53 PM 2,630 views

I would like to customize the Project Task model's user_id field , so that it only allows to select only from the Task project's team members.

I already tried adding this to the field in the form's XML:

domain="[('id','child_of',project_id.members)]"

But no success. Any suggestions?

You can use the role in group to do this.

OpenERP Vietnam
on 8/30/13, 6:12 AM

Role in group? I'm not familiar with that.

Daniel Reis
on 8/30/13, 6:29 AM

You access menu Settings - Users - Groups. In group which you want to fix, do this on tab Rules (add new rule with "Rule Definition (Domain Filter)"). Link: https://lh5.googleusercontent.com/-I9cHAewfEIY/UiBZy5QrfQI/AAAAAAAAANg/-U8kVoHsctM/w1044-h569-no/rule.png

OpenERP Vietnam
on 8/30/13, 6:35 AM

any other simpler solution for this question?

dirtyHandsPHP
on 1/15/15, 12:56 AM
2
Torsten Francke
On 9/2/13, 10:43 AM

Hi Daniel,

what is overriding "onchange_project(project_id)" method and adding: domain for user_id there? you have the project_id so you can load the members and can add the list in return

As i read https://doc.openerp.com/6.0/developer/2_6_views_events/events/events/ correctly onchange methods can return not only values and warning but also "domain"

EDIT i just test my idea with a short modul for OpenERP 7 and it works, look at the code:

from openerp.osv import fields, osv
from openerp.addons.base_status.base_stage import base_stage

class task(base_stage, osv.osv):
    _name = "project.task"
    _inherit = "project.task"

    def onchange_project(self, cr, uid, id, project_id, context=None):
        if project_id:
            project = self.pool.get('project.project').browse(cr, uid, project_id, context=context)
            members = []            
            for m in project.members:
                members.append(m.id)
            if project and project.partner_id:
                return {'value': {'partner_id': project.partner_id.id},
                        'domain': {'user_id':[('id','in',members)]}}
            return {'domain': {'user_id':[('id','in',members)]}}
        return {}

task()

Greetings Markus

Nice hack. I wish there could be a simpler solution though. But if there isn't I'll try that. +1

Daniel Reis
on 9/2/13, 7:59 PM

Daniel, I use this hack to because I found no working domain filter to do the job ...

Tuxservices, Jeudy Nicolas
on 9/3/13, 7:49 PM

This won't work when the project has not been changed. i.e opening an existing record in form view. In this case, one can select any user as member...

René Schuster
on 8/21/14, 8:54 AM

any other simpler solution for the above question other than this one?

dirtyHandsPHP
on 1/15/15, 12:57 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: 8/28/13, 1:53 PM
Seen: 2630 times
Last updated: 3/16/15, 8:10 AM