Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
2 Antwoorden
3443 Weergaven
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?

Avatar
Annuleer
Beste antwoord

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!

Avatar
Annuleer
Beste antwoord

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

Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
3
okt. 18
3495
3
sep. 16
5793
0
mrt. 15
3214
1
mrt. 15
3860
3
mei 25
2689