This question has been flagged
2 Replies
3450 Views

I have two models like

class BsService(models.Model):
    _name = 'bs.service'
    ....
    users = fields.Many2one('res.users', string="Users", readonly=True)
    ....
    ....
class BsSaleOrder(models.Model):
    _name = 'bs.sale.order'
    
    service_id = fields.Many2one('bs.service', string='Service', required=True)
    service_user = fields.Many2one('res.users', string='Service User')
    ...
    ...

Now, In BsSaleOrder View, I want to show only those users are related to a selected service. If user not found in the selected service,  all res.users would be shown.

Avatar
Discard

You said: "You want to show show only those users are related to a selected service."

In your code , you use:

users = fields.Many2one('res.users', string="Users", readonly=True)

That's mean only one user will be linked to each service.

In BsSaleOrder, you can use domain to filter the users depend on users field in BsService module.

Best Answer

I cannot understand your question, but i think you need dependent drop down or Many2one. I mean on the change of one field you need the value of another fields that are dependent on first field.

Example:

how to create a dependent drop down (many2one) fields in Odoo. For example I have two many2one fields (campus_id and department_id), and we want to change the department on the basis of campus field.

1 @api.onchange('campus_id')
2 def _campus_onchange(self):
3     res = {}
4     res['domain']={'department_id':[('campus_id', '=', self.campus_id.id)]}
5     return res

Hope this will helpful in your case, to get more detail read: http://learnopenerp.blogspot.com/2016/10/onchange-many2one-filed-in-odoo.html

Avatar
Discard