Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
2244 Widoki

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

Awatar
Odrzuć
Autor Najlepsza odpowiedź

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



Awatar
Odrzuć

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?

Autor

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

It is strange that Odoo gives you this warning when you are editing an Extension View created by Studio (to overcome the limitation described here) but it should be fine to do that!

It's also a good idea to keep a backup of the XML in the Extension View in case it gets lost in an upgrade.

Najlepsza odpowiedź

Hi, you can follow this: https://youtu.be/f3mq5fHRPT0

Hope it helps, Thanks

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
paź 24
1688
2
paź 24
3013
1
wrz 24
1201
1
lip 24
2271
0
cze 24
1172