Pyson syntax for 'states' attribut in a view


#1

Hi,
Is there somewhere a sample of the syntax that i must used in the attribut state in a view ?

I try:

states="{‘invisible’: Not(Eval(‘template.is_wine’))}"

it don’t work (but wihout error)

states="{‘invisible’: 1}"

I have the following error:

Expecting property name enclosed in double quotes: line 1 column 2 (char 1)

Regards


(albert) #2

Which tryton version are you using?

Newer versions don’t accept the states attribute but you should use: “view_attributes()” method.

For example:

http://hg.tryton.org/modules/commission/file/tip/invoice.py#l192


#3

Tryton 5.0.3

Ok, thanks for the info, I read that in the doc, but it must not be up to date.


(albert) #4

It is, indeed:

http://docs.tryton.org/projects/server/en/latest/ref/models/models.html?highlight=view_attributes#trytond.model.ModelView.view_attributes


#5

I think 2cadz talked about the ‘states’ attribute as described in the views docs : http://docs.tryton.org/projects/server/en/latest/topics/views/index.html#xml-description. Not obvious that the Pyson expression can’t be stated direcly in the view’s xml.

BTW, view_attributes works for the client, but doesn’t seems to be supported by Sao (at least, for the ‘invisible’ attribute).


(Sergi Almacellas Abellana) #6

Probably this is for historical reasons as on previous versions it was possible to define the PYSON Expresion on the view directly. It will be great if you can contribute to improve it.

The behaviour should be the same for both clients, it sounds like a sao bug. Could you please fill an issue with some sample code in order to reproduce it?

Thank you so much!


#7

Fine, i’d be glad to be of any help.

Not sure how to contribute to the docs…

Nevertheless, I’m trying to write some code for testing the clients behavior.
But I can’t manage to access fields with xpath. I tried to use : ‘//field[@id=“field_id”]’ but doesn’t seems to work by any mean…
How to do so (could find any example in modules source code, exepted for the above widgets).


#8

Normally replacing a field by its name (id attribute does not exist it seems to me)

//field[@name=“field_name”]


#9

I must be lame but fields can’t be selected, even with ‘//field’…


#10

Here a sample : modules/account_invoice_line_standalone: 9807b325e2e5 view/invoice_line_tree_sequence.xml


#11

OK, It seems that sao doesn’t update the class attribute ‘active’ of the content div when the page is set to invisibility. I filled a bug report : https://bugs.tryton.org/issue7923.

I still can’t select any field with view_attributes. I’ll investigate later.


(Sergi Almacellas Abellana) #12

You should submit a patch against the doc folder of the trytond repository. The docs are build using Sphinx


(system) #13

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.