main entity and lines

22 views
Skip to first unread message

Cato Nano

unread,
Jan 28, 2018, 12:12:47 PM1/28/18
to tryton
Some time ago I asked how to have on my Bolletta lines fields defined on the main entity, the Bolletta

I did this with some date fields and it worked like a charm.

Now I need to read the value of a selection field, defined on Bolletta

In fact, I have to assign the "invisible" state to a field on the base of a selection on a selection field on Bolletta

It doesn' t work

How do I read the content of a selection field from a line ?

Thanks

Sergi Almacellas Abellana

unread,
Jan 29, 2018, 4:05:17 AM1/29/18
to try...@googlegroups.com
El 28/01/18 a les 18:12, Cato Nano ha escrit:
> Some time ago I asked how to have on my Bolletta lines fields defined on the main entity, the Bolletta
>
> I did this with some date fields and it worked like a charm.
>
> Now I need to read the value of a selection field, defined on Bolletta
>
> In fact, I have to assign the "invisible" state to a field on the base of a selection on a selection field on Bolletta
>
> It doesn' t work
>

What does not work? Could you provide more information please?

> How do I read the content of a selection field from a line ?

If you are going to evaluate it on pyson, you should create a functional
field. Here is an example:

http://hg.tryton.org/modules/account_invoice/file/6c85f394741c/invoice.py#l1455

--
Sergi Almacellas Abellana
www.koolpi.com
Twitter: @pokoli_srk

Cato Nano

unread,
Jan 29, 2018, 2:28:05 PM1/29/18
to tryton
Il giorno lunedì 29 gennaio 2018 10:05:17 UTC+1, Sergi Almacellas Abellana ha scritto:
> El 28/01/18 a les 18:12, Cato Nano ha escrit:
> > Some time ago I asked how to have on my Bolletta lines fields defined on the main entity, the Bolletta
> >
> > I did this with some date fields and it worked like a charm.
> >
> > Now I need to read the value of a selection field, defined on Bolletta
> >
> > In fact, I have to assign the "invisible" state to a field on the base of a selection on a selection field on Bolletta
> >
> > It doesn' t work
> >
>
> What does not work? Could you provide more information please?

yes, I can provide mor einformation, sorry



> > How do I read the content of a selection field from a line ?
>
> If you are going to evaluate it on pyson, you should create a functional
> field. Here is an example:
>
> http://hg.tryton.org/modules/account_invoice/file/6c85f394741c/invoice.py#l1455


Thanks

I made this field. the thing runs, but the field doesn't appear
https://gitlab.com/humanitiesNerd/tributi/blob/master/affissione.py#L97

I' d like to be able to debug this not appearance myself

How would you do, if you were in my shoes ?
Would you use Proteus on a SQLite db for debugging this ?

Sergi Almacellas Abellana

unread,
Jan 31, 2018, 11:33:35 AM1/31/18
to try...@googlegroups.com
El 29/01/18 a les 20:28, Cato Nano ha escrit:
> I made this field. the thing runs, but the field doesn't appear
> https://gitlab.com/humanitiesNerd/tributi/blob/master/affissione.py#L97

The problem is that self.bolletta.tipo is not a field of the model. You
can not use the dot notation to navigate on pyson statements, so you
should create a functional field that returns the value of the
referenced field.

Cato Nano

unread,
Feb 2, 2018, 2:10:43 AM2/2/18
to tryton
Il giorno mercoledì 31 gennaio 2018 17:33:35 UTC+1, Sergi Almacellas Abellana ha scritto:
> El 29/01/18 a les 20:28, Cato Nano ha escrit:
> > I made this field. the thing runs, but the field doesn't appear
> > https://gitlab.com/humanitiesNerd/tributi/blob/master/affissione.py#L97
>
> The problem is that self.bolletta.tipo is not a field of the model. You
> can not use the dot notation to navigate on pyson statements, so you
> should create a functional field that returns the value of the
> referenced field.

Ah, I will try this.
Thanks !

Cato Nano

unread,
Feb 2, 2018, 3:17:38 AM2/2/18
to tryton
I tried

Not only the field had to belong to the model but also I had to move from this

states={'invisible': Eval('bollettaTipo') != 'commerciale'}

to this

states={'invisible': (Eval('bollettaTipo') != 'commerciale')}

in order for it to work :-)
Reply all
Reply to author
Forward
0 new messages