Skip to Content
Menú
This question has been flagged
2 Respostes
9866 Vistes

Hello, I need help with the relation to dynamic domains in Odoo v 15

in Odoo v13 I used @api.onchange and return [('name','in',vals)]

Example:

@api.onchange('field_1')
def onchange_domain(self):
    vals = []
    objs = self.env['model'].search([])
    for obj in objs:
        vals.append(obj.code)         return {'domain' : {'field_2' : [('name', 'in', vals)]}}

In Odoo v14 the console says that the method is deprecated and in OCA I found the module called "web_domain_field" which has helped me a lot to manage dynamic domains using @api.depends and return json array to field char.


< --field name-=-"product_id_domain" invisible=-"1" -/- >
< --field-name-=-"product_id" domain=-"product_id_domain"-/- >

product_id_domain = fields.Char(
    compute="_compute_product_id_domain",
    readonly=True,
    store=False,
)
@api.multi
@api.depends('name')
def _compute_product_id_domain(self):
    for rec in self:
        rec.product_id_domain = json.dumps(
            [('type', '=', 'product'), ('name', 'like', rec.name)]
        )

But now in Odoo v15 there is no such module so reviewing the Odoo source code I can't find a simple way to handle this, someone who has already made a method that works in odoo v15 ?

Avatar
Descartar
Best Answer

Hi,

It seems there is a PR for the web_domain_field for v15 in the oca web repository. Hope it will get merged soon and till then you can try to get it from here:  https://github.com/rven/web/tree/15.0-mig-web_domain_field


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

 Thanks

Avatar
Descartar
Autor

thank you very much for the prompt reply :D
I'm going to try the module
I also hope that it will merge soon since that way of doing dynamic domain has been a great help to me

Best Answer

You can follow this: https://youtu.be/XGqXEL2qQmE

Hope it helps,

Thanks

Avatar
Descartar
Related Posts Respostes Vistes Activitat
2
de des. 20
4662
1
de maig 24
5320
0
de gen. 24
941
1
de des. 21
4259
2
de maig 24
1831