Skip to Content
Menu
This question has been flagged

In mrp.workorder I'm trying to add a Many2one field to hr.employee. I'd like this list filtered so that it only shows employees that are in the correct department for that workcenter. 

I also have a new model called mrp.workcenter.types so that I can associated multiple workcenters of a similar type together. 

And hr.department is associated with mrp.workcenter.types. I've been trying to make a domain that connects these all together. Something like:

hr.employee -> hr.department -> mrp.workcenter_types -> mrp.workcenter


I've tried using related fields and domains like hr.employee.id.hr.department.id.mrp.workcenter_types.id., etc, etc. without any luck in the hr.employee many2one field. Any ideas? 

class MRPWorkCenterInherit(models.Model):
    _inherit = 'mrp.workcenter'
    _description = 'Adds Workcenter Types'

    workcenter_types = fields.Many2one('mrp.workcenter.types')


class MRPWorkOrderInherit(models.Model):
    _inherit = 'mrp.workorder'
    employee_id = fields.Many2one('hr.employee')

class HRDepartmentWorkCenterTypeInherit(models.Model):
    _inherit = 'hr.department'
 
    workcenter_types = fields.Many2one(
        string='Workcenter Type',
        comodel_name='mrp.workcenter.types',
        ondelete='restrict',
    )

class MRPWorkCenterTypes(models.Model):
    _name = 'mrp.workcenter.types'

    name = fields.Char()
Avatar
Discard
Related Posts Replies Views Activity
1
May 24
1308
2
Apr 23
4983
1
Nov 22
3300
2
Jul 22
2099
2
May 18
8875