跳至內容
選單
此問題已被標幟
2 回覆
2240 瀏覽次數

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

頭像
捨棄
作者 最佳答案

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



頭像
捨棄

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?

作者

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.

最佳答案

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

Hope it helps, Thanks

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
1
10月 24
1688
2
10月 24
3011
1
9月 24
1201
1
7月 24
2271
0
6月 24
1172