Apply domain in Many2One

28 views
Skip to first unread message

Peter Müller

unread,
Mar 10, 2017, 3:30:06 AM3/10/17
to tryton-dev
Hi,

I try to put a reference from a party to a party. The referenced party will be the party that will pay the invoices.

The field on the form is made as widget="selection".

I don't want that the user can select the same party as the refernced party. So I want to apply the domain to show all parties, but the current.

Probably I have wrong the Eval expression and cannot found further documentation.

Regards.

from trytond.model import fields
from trytond.pool import PoolMeta
from trytond.pyson import Eval

__all__
=['Party']

__metaclass__
= PoolMeta


class Party:
    __name__
= 'party.party'
    payer
= fields.Many2One('party.party','Payer',domain=[('code','!=',Eval('code'))])




Cédric Krier

unread,
Mar 10, 2017, 4:00:07 AM3/10/17
to tryton-dev
And what is not working?
For me, you have just forgot to add 'code' to depends.
And instead of 'code', you could use 'id'.

--
Cédric Krier - B2CK SPRL
Email/Jabber: cedric...@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/

Peter Müller

unread,
Mar 10, 2017, 5:45:06 AM3/10/17
to tryton-dev

Ok, got this know. May I ask, the drop down selection shows only the code. Is it possible to show other fields (name, etc) ?

Thank you.

El divendres, 10 març de 2017 10:00:07 UTC+1, Cédric Krier va escriure:

Sergi Almacellas Abellana

unread,
Mar 10, 2017, 5:59:48 AM3/10/17
to tryto...@googlegroups.com
El 10/03/17 a les 11:30, Peter Müller ha escrit:
>
> Ok, got this know. May I ask, the drop down selection shows only the
> code. Is it possible to show other fields (name, etc) ?
Just remove the widget="selection" to use the default Many2ONe widget
which provides this functionality.

IIRC the selection widget only shows the party rec_name

P.S: Don't top post in this mailing list. See
http://groups.tryton.org/netiquette

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

Cédric Krier

unread,
Mar 10, 2017, 7:10:09 AM3/10/17
to tryto...@googlegroups.com
On 2017-03-10 11:59, Sergi Almacellas Abellana wrote:
> El 10/03/17 a les 11:30, Peter Müller ha escrit:
> >
> > Ok, got this know. May I ask, the drop down selection shows only the
> > code. Is it possible to show other fields (name, etc) ?
> Just remove the widget="selection" to use the default Many2ONe widget which
> provides this functionality.
>
> IIRC the selection widget only shows the party rec_name

They both only show the rec_name which represent the name of the record.
I do not know but maybe it could be a feature to allow to define a
different Char field than the rec_name. But it will depend on how easy
it is.
Reply all
Reply to author
Forward
0 new messages