Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
28551 Zobrazení

    @http.route(['/signage','/signage/list'],type='http', auth='user', website=True)
    def signage_list(self, **post):
        return request.render('signage.signage_list', {'signages': request.env['signage.signage'].search([('state','=','open')])})

ORDER BY! How do I write it Odoo style!?

Avatar
Zrušit
Nejlepší odpověď

Hi,

See a sample code of order done in the search method,

partner_sales = self.env['sale.order'].search([('partner_id','=', partner)], order="id desc")


In the above example the search method will return the result in the descending order of the id.


Thanks

Avatar
Zrušit

note: if you use search_read, then you could try search_read(order="id desc")

Autor Nejlepší odpověď

Thank you! It's the same answer as I found myself, but I got the details mixed up... :-)
Another answer would be: <ul t-foreach="signages.sorted(lambda s: s.template_id)" t-as="signage">
but I like "order", the way you write!

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
2
čvc 25
4638
2
pro 24
7780
2
kvě 24
7492
3
bře 24
6920
0
bře 24
1564