Pyson syntax for 'states' attribut in a view

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

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

1 Like

Tryton 5.0.3

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

It is, indeed:

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

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).

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!

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).

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

//field[@name=“field_name”]

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

Here a sample : modules/account_invoice_line_standalone: 6e25c153cce8 view/invoice_line_tree_sequence.xml

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.

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

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