It is currently Sat Feb 11, 2012 10:24 am

All times are UTC + 2 hours




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: using variable in invisible in XML
PostPosted: Wed Mar 03, 2010 2:45 am 
Offline

Joined: Fri Jan 12, 2007 12:25 pm
Posts: 90
Location: casablanca
hello
in XML view, I want to hide some tag depending to a condition :
if %(chaine)s is not in variable then i want : visible=True

First solution :
I initialized a context with :
context["variable"]=['chaine1','chaine2','chaine3']

tag="""<field>"""

but the context dont containe variable

Seconde solution , initializing variable directly :

variable =['chaine1','chaine2','chaine3']

tag="""<field>"""

I get error , Keyerror, variable is not defined

_________________
Almanar, Linux kernel 2.6.28-16, Ubuntu 9.04, Openerp 5.0.6, python 2.5 ou 2.6


Top
 Profile  
 
 Post subject: weird behaviors...
PostPosted: Wed Mar 03, 2010 7:26 pm 
Offline

Joined: Wed Feb 24, 2010 1:22 pm
Posts: 3
Hi there,
I got the same problems, the facts are :
1 -
Code:
<field name="prenom" attrs="{'invisible': [('nom', '=', 'amine') ] }" />
('nom' is a field definition, not a string) doesn't work! Tip to make it work consist to embed it in a <group> tag, eg:
Code:
<group attrs="{'invisible': [('nom', '=', 'amine') ] }"><field name="prenom"  /></group>
. note that the group tag is not labelled (no 'string' attribute), so visually not different from a naked <field/> tag.
But that trick simply not working on a tree view: the "group" tag inside a tree view make the field to be always hidden.

2- using
Code:
<field name="prenom" invisible=" 'nom' == 'amine' " />
is perfectly working but useless, since 'nom' here is considered as a string, not a field content. doing
Code:
<field name="prenom" invisible=" nom == 'amine' " />
is more pythonic, but raises an error: 'nom' is not defined!. the attributes cannot access the field content like in point 1!. The "product" module is using that kind of construction in "product_view.xml":
Code:
<field invisible="'partner_id' not in context" name="price"/>
. it seems to work! but it uses the context dictionnary. good luck to understand that code, since there's no piece of documentation about the context dictionnary, and openerp make a heavily use of the context.
it's really frustrating, testing each combinaison is time consumming, and some documentation about the context dictionnary would be really welcome.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 04, 2010 2:28 am 
Offline

Joined: Sat Jan 16, 2010 2:59 am
Posts: 27
Location: Australia
The attrs seems to only work in the web client, not GTK

so:
Code:
<field name="prenom" attrs="{'invisible': [('nom', '=', 'amine') ] }" />


will work as expected only in web client.

I also noticed that if you compare the Product tree view between web client and GTK client, the List price only shows up in GTK, because GTK doesn't seem to understand invisible.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 04, 2010 2:31 am 
Offline

Joined: Sat Jan 16, 2010 2:59 am
Posts: 27
Location: Australia
http://www.openobject.com/forum/topic6873.html

seems it never made it into the GTK client after all.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 04, 2010 11:18 am 
Offline

Joined: Fri Jan 12, 2007 12:25 pm
Posts: 90
Location: casablanca
In GTK client, I try invisible with <group> tag, and it success,
But only in form view

code:
<group>
<field>
</group>

_________________
Almanar, Linux kernel 2.6.28-16, Ubuntu 9.04, Openerp 5.0.6, python 2.5 ou 2.6


Last edited by Almanar on Thu Mar 04, 2010 11:26 am, edited 2 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 04, 2010 11:22 am 
Offline

Joined: Fri Jan 12, 2007 12:25 pm
Posts: 90
Location: casablanca
No i don't agree.
I try invisible with <group> tag, then it success, but only in form view, in GTK client.

<group>
<field>
</group>

But it doesn't work in tree view.
And I want to hide some column in tree view

I think it's a bug

_________________
Almanar, Linux kernel 2.6.28-16, Ubuntu 9.04, Openerp 5.0.6, python 2.5 ou 2.6


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 04, 2010 6:04 pm 
Offline

Joined: Fri Jan 12, 2007 12:25 pm
Posts: 90
Location: casablanca
Hi,
Look at this entry in launchpas bugs:
https://bugs.launchpad.net/openobject-c ... bug/531814
How can we solve this bug.

Invisible attribute work in Web client and not in GTK.

Invisible in <group> tag work in form view and not in tree

_________________
Almanar, Linux kernel 2.6.28-16, Ubuntu 9.04, Openerp 5.0.6, python 2.5 ou 2.6


Top
 Profile  
 
 Post subject: another way to do it, but...
PostPosted: Tue Apr 06, 2010 7:41 pm 
Offline

Joined: Wed Feb 24, 2010 1:22 pm
Posts: 3
Another way to alter columns in tree view (hide a column depending of a condition) is to use fields_view_get and fields_get, orm methods poorly documented too, but very useful.
The problem is that methods signatures:
def fields_view_get(self, cr, uid, view_id=None, view_type=’form’, context=None, toolbar=False)
Note that there is not "ids" param, so you cannot alter a specific objet or instance depending of a parameter of the actual objet: it will blindly alter ALL the instances. all the code in the overrided fields_get cannot deal with specific instances.
Any idea to achieve that, folks?


Top
 Profile  
 
 Post subject: the same problem :S
PostPosted: Mon Apr 26, 2010 12:18 pm 
Offline

Joined: Mon Jan 18, 2010 8:07 pm
Posts: 17
Hello,

is ORing working with OpenERP web client?
example: {'invisible':['|',('referencenumber','=','01'),('state','=','care_closed')]} a valid syntax?


I am sure that AND is working but OR is not.. I am tested it on 5.0.7 and 5.0.9 .. any idea?


Top
 Profile  
 
 Post subject: another addition
PostPosted: Mon Apr 26, 2010 12:19 pm 
Offline

Joined: Mon Jan 18, 2010 8:07 pm
Posts: 17
I am testing it on the form.. also, I have used group and make the field inside but also it didn't work...


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC + 2 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:

Protected by Anti-Spam ACP