Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
4617 Vizualizări

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.

Imagine profil
Abandonează

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.

Cel mai bun răspuns

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

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
1
nov. 18
2971
2
sept. 18
7293
2
feb. 24
15603
1
dec. 22
5035
2
dec. 22
14529