콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
3451 화면
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?

아바타
취소
베스트 답변

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!

아바타
취소
베스트 답변

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

아바타
취소
관련 게시물 답글 화면 활동
3
10월 18
3501
3
9월 16
5799
0
3월 15
3222
1
3월 15
3861
3
5월 25
2710