Se rendre au contenu
Menu
Cette question a été signalée
2 Réponses
28122 Vues

    @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
Ignorer
Meilleure réponse

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
Ignorer

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

Auteur Meilleure réponse

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
Ignorer
Publications associées Réponses Vues Activité
2
juil. 25
4187
2
déc. 24
7441
2
mai 24
7195
3
mars 24
6626
0
mars 24
1443