Odoo Help


Many2One inside One2Many domain filter from Many2Many

Munesh Nandwani
on 5/17/16, 10:44 AM 1,224 views

In workcenter I create many2many in relation between workcenter_id and employee_id. Then in work order I created One2Many with field employee_id as many2one.

many2Many in workcenter:

class mrp_workcenter(osv.osv):

_description = "Work center link with employee"

_inherit = 'mrp.workcenter'

_columns = {

'workcenter_user': fields.many2many('hr.employee','employee_workcenter_rel', 'workcenter_id', 'employee_id', 'Employee'),


In workorder (mrp.production.workcenter.line):

class mrp_production_workcenter_line(osv.osv):

_inherit = 'mrp.production.workcenter.line'

_columns = {

'emp_wc_ids': fields.one2many('emp.wc.line', 'workorder_id', 'Workers', copy=True),


class emp_wc_line(osv.osv):

_name ="emp.wc.line"

_description ="Work Order link with employee"

_employee_domains = []


def get_employee_ids(self, cr, uid, ids, context=None):

workorder_obj = self.pool.get('mrp.production.workcenter.line')

workorder = workorder_obj.browse(cr, uid, ids, context=context)

del self._employee_domains[:]

if workorder.workcenter_id.workcenter_user:

for enter in workorder.workcenter_id.workcenter_user:


    _columns = {

'employee_id' : fields.many2one('hr.employee', 'Name', domain=[('id', 'in', _employee_domains)], ondelete='restrict', select=True),


When I select the employee_id it doesn't show any data. It didn't manage to get any employee that  I declare inside the Many2Many in Workcenter. 

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: 5/17/16, 10:44 AM
Seen: 1224 times
Last updated: 5/17/16, 11:17 AM