Created
May 20, 2022 05:40
-
-
Save sehrishnaz/5d55179a69c86d5a56d5f8fc53cbb14a to your computer and use it in GitHub Desktop.
Set Multiple Domain Filter on Many2many Field Onchange of Many2one in Odoo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@api.onchange('field_1','field_2','field_3','field_4','field_5') | |
def onchange_of_fields(self): | |
res={} | |
res['domain'] = {'many2many_field': []} | |
for each in self: | |
if each.field_1: | |
res['domain']['many2many_field'].append(('field_1', '=', each.field_1.id)) | |
if each.field_2: | |
res['domain']['many2many_field'].append(('field_2', '=', each.field_2.id)) | |
if each.field_3: | |
res['domain']['many2many_field'].append(('field_3', '=', each.field_3.id)) | |
if each.field_5: | |
res['domain']['many2many_field'].append(('field_5', '=', each.field_5.id)) | |
return res | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Set Multiple Domain Filter on Many2many Field Onchange of Many2one in Odoo