Skip to Content
Menu
This question has been flagged
1 Reply
302 Views

Hello.

I'm using Odoo 17.2 (the Online version, so no direct access to code).


Lot of literature about using dynamic domains in Odoo, but very few info on how to implement it with Studio.


I have a Many2One field and this domain attached: [('categ_id', '=', 12)] and works perfectly.

I want now to have a different domain (for example [('categ_id', '=', 16)] )if a Boolean field is = True. 

Let's say is_custom is a Checkbox field: 

if is_custom:

​my domain should be [('categ_id', '=', 12)]

else:

​my domain should be [('categ_id', '=', 16)]


Is this possible in Odoo 17+ using Studio + Automations ?


Thanks a lot in advance for the info

LB

Avatar
Discard
Author Best Answer

It seems a bug in the Studio interface what prevents you to write a dynamic domain in this way:

​[('categ_id', '=', x_studio_material_filter_cat_id)]

The workaround id to write the domain in wrongly by quoting the x_studio_material_filter_cat_id variable, like this:

​[('categ_id', '=', 'x_studio_material_filter_cat_id')]

In this way the interface let's you write the domain in this way.

Then you go on the view xml, you search for your domain and manually remove the ' ' quotes from there, basically restoring the working syntax: [('categ_id', '=', x_studio_material_filter_cat_id)] .

Hope it helps,

LucaB



Avatar
Discard

For the SaaS version, there is a warning to not edit the xml of the views. Do you have a way to get around this?

Author

Anthony G -> my personal opinion on that warning (to not edit directly the views) is that its a general advise to not structurally modify directly the views, but instead "Extend" them using inheritance so to reduce the risk of being overwritten on software updates ... but here the change on the view is just those ' characters, I believe it would be fine.
Other than this, just keep an eye on the view on every upgrade (from my side I can tell you that from the 17.2 to the 17.4 upgrade the view still works fine :)

LucaB

Related Posts Replies Views Activity
2
Oct 24
860
1
Sep 24
70
1
Jul 24
216
0
Jun 24
187
2
Feb 24
1009