German
(German Dario Alvarez)
October 31, 2019, 4:12am
1
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.
2cadz
(Christophe)
October 31, 2019, 5:59am
2
Hello,
In the get_rate method of currency module you can find an example of search with limit, order and usage of context.
Regard
German
(German Dario Alvarez)
October 31, 2019, 6:49pm
3
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')])
Also the solution for my own problem was to use on_change_with_field method and not default_field.
Thanks!
system
(system)
Closed
November 30, 2019, 6:49pm
4
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.