New behavior

12 views
Skip to first unread message

Cédric Krier

unread,
Feb 12, 2009, 10:59:20 AM2/12/09
to tryton
With the refactoring, we have simplify the read function by removing the
classic_read and classic_write. This means that when we read a many2one,
we read also the name of the record. This is an overload but it needed
by the client to display the many2one value (the name of the record)
without making an other request to the server.

We want to change this by a new behavior:

- adding by default a function field rec_name the return the value from
name_get
- allow to use in the call of read, some fields like this party.name
where party is a many2one
- change the client to add in the read call the field "many2one".rec_name
- and finaly, removing the get function on many2one so it will no more
return a tuple (id, name)

To acheive this we had some issues that we must fix:

- the name_get and name_search function doesn't have a signature for a
function field.
- the name_get and name_search have not a good name, we would prefere
get_rec_name and search_rec_name

So those changes will force to fix all the modules but I think it will
clarify the situation.

What do you think?

--
Cédric Krier

B2CK SPRL
Rue de Rotterdam, 4
4000 Liège
Belgium
Tel: +32 472 54 46 59
Email: cedric...@b2ck.com
Jabber: cedric...@b2ck.com
Website: http://www.b2ck.com/

udono

unread,
Feb 12, 2009, 1:29:37 PM2/12/09
to Tryton
Hi Cédric,
this seems a good change. But I don't understand the exactly meaning
of the changes.
Could you provide some example code how the actual API or signatures
change?

Cheers Udo

Cédric Krier

unread,
Feb 12, 2009, 1:40:22 PM2/12/09
to try...@googlegroups.com

There will be a new field on every Models:

rec_name = fields.Function('get_rec_name', type='char', string='Name',
fnct_search='search_rec_name')


the name_get function:

def name_get(self, cursor, user, ids, context=None):

will become:

def get_rec_name(self, cursor, user, ids, name, arg, context=None):

and the name_search function:

def name_search(self, cursor, user, name='', args=None, operator='ilike',
context=None, limit=None):

will become

def search_rec_name(self, cursor, user, name, args, context):


This is the external API that will change.

Cédric Krier

unread,
Feb 17, 2009, 6:26:44 AM2/17/09
to try...@googlegroups.com
On 12/02/09 19:40 +0100, Cédric Krier wrote:
> On 12/02/09 10:29 -0800, udono wrote:
> >
> > Hi Cédric,
> > this seems a good change. But I don't understand the exactly meaning
> > of the changes.
> > Could you provide some example code how the actual API or signatures
> > change?
> >
>
> There will be a new field on every Models:
>
> rec_name = fields.Function('get_rec_name', type='char', string='Name',
> fnct_search='search_rec_name')
>
>
> the name_get function:
>
> def name_get(self, cursor, user, ids, context=None):
>
> will become:
>
> def get_rec_name(self, cursor, user, ids, name, arg, context=None):
>
>
>
> and the name_search function:
>
> def name_search(self, cursor, user, name='', args=None, operator='ilike',
> context=None, limit=None):
>
> will become
>
> def search_rec_name(self, cursor, user, name, args, context):
>
>
> This is the external API that will change.
>

It is pushed.
So please test it as it is a big change and report issue to
http://bugs.tryton.org/

Reply all
Reply to author
Forward
0 new messages