How to use the ModelStorage search arguments

Hello dear tryton team,
May someone please help me giving an example of how order by create_date on ‘DESC’?, It’s not clear for me how to pass the order or limit to search ( a list inside another list?, I don’t get it)

classmethod ModelStorage.search ( domain [, offset [, limit [,order [, count ]]]])
I’m trying with:
Product.search((‘create_date’,’=’,‘my_date’)…)

I’m using this search inside default_product function, is it possible to pass a current selected ( context ) party to this kind of search?

Thanks in advance, my apologies if the question it’s to simple.

Hello,

In the get_rate method of currency module you can find an example of search with limit, order and usage of context.

Regard

Hello @2cadz,
Thank you so much, you were right, I found it:

        rates = Rate.search([
                ('currency', '=', currency.id),
                ('date', '<=', date),
                ], limit=1, order=[('date', 'DESC')])

:grinning: Also the solution for my own problem was to use on_change_with_field method and not default_field.

Thanks!

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