Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
4652 Lượt xem

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.

Ảnh đại diện
Huỷ bỏ

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.

Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 11 18
3009
2
thg 9 18
7369
2
thg 2 24
15648
1
thg 12 22
5073
2
thg 12 22
14586