Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
13085 Tampilan

I am trying to have a field that will have 'no_open' set to True if a given condition is true and have it be False otherwise.

I tried using domain filters...

<field name="partner_id" string="Contact Search" options="{'no_open': [('stage_type_name','=','Rejected)]}" />

My expectation was that the no_open will be set to False if the condition was false and to True if it is true. But it didn't work out. It sets it to true regardless of the output of the domain filter. Then I did this:-

<field name="partner_id" string="Contact Search" attrs="{'invisible' : [('stage_type_name', '=', 'Rejected')]}" />
<field name="partner_id" string="Contact Search Readonly" attrs="{ 'invisible' : [('stage_type_name','!=','Rejected')]}" options="{'no_open': True}"/> 

I thought this should fix the issue but unfortunately the options automatically get taken from the last instance of the field for that field name. So it takes the options field from whichever ends up at the bottom. Invisible simply hides it from view rather than render it invalid.

I would like to set the option to True or False depending on a certain condition based on the value of a certain value in the form.

Avatar
Buang

In your second solution, did you try to put no_open: True in the fist field and then no_open:False in the second ? Because i see that you added no_open: True to both fields

Penulis

@ibrahim, sorry that was a mistake in my question. I had tried it properly in the actual code. Fixed the code in the question as well.

Jawaban Terbai

This doesn't answer your second question, but it might help other people reading this.  

Some attributes can be made conditional, whilst other cannot. As you have observed, although it's possible to add a domain filter to no_open it is ignored whereas this works fine for invisible and others.

And no_open blocks the "External Link" (screenshot here)

Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
1
Mei 24
2464
1
Nov 22
4771
2
Jul 22
3523
2
Mei 18
9705
2
Jul 17
6603