Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
3444 Lượt xem
class HelpdeskTeam(models.Model):
....
category_ids= fields.Many2many(comodel_name="helpdesk.ticket.category", string="Category")
....

class HelpdeskTicket(models.Model):
....
team_id= fields.Many2one(comodel_name="helpdesk.ticket.team",string="Area")
category_id= fields.Many2one(comodel_name="helpdesk.ticket.category",string="Category")
....

in the form view:
....
...fieldname="category_id"domain="[(category_id, 'in', 'team_id.category_ids')]"...
....


Can I add a conditional field to show specific values in the list?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,
You can add domain for one field based on another field using onchange.


@api.onchange('team_id')
def get_categories(self):
​if self.team_id:
​domain = [('field_name', '=', value)]
​else:
​domain = []
​return {'domain': {'category_id': domain}}


You can read more about dynamic domain from this blog:
https://www.cybrosys.com/blog/how-to-apply-dynamic-domain-for-relational-fields-in-odoo-16


Hope it helps!

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

Using the domain attribute you can filter the value listed in all the fields, the domain expression has to be written in the needed format. Domain can be applied in python level as well as in the view level.


If you look at this video, you will get detailed idea about it and you can map it according to your need:  

https://www.youtube.com/watch?v=dq5Vtj_pwuI


Thanks

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 10 18
3496
3
thg 9 16
5793
0
thg 3 15
3214
1
thg 3 15
3860
3
thg 5 25
2690