Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
27330 Vizualizări

    @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!?

Imagine profil
Abandonează
Cel mai bun răspuns

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

Imagine profil
Abandonează

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

Autor Cel mai bun răspuns

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!

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
2
dec. 24
6938
2
mai 24
6712
3
mar. 24
6134
0
mar. 24
1138
3
feb. 24
12370