Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
28660 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ

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

Tác giả Câu trả lời hay nhất

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!

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 7 25
4773
2
thg 12 24
7878
2
thg 5 24
7566
3
thg 3 24
7014
0
thg 3 24
1641