I paginated the search result. For the first, query set gives me perfect result , but the pagination set all pages, and I get all data from database by clicking on any page number.
Here is my code:
This is the controller which I added :
class MyCustomWeb(http.Controller): @http.route(['/customer', '/customer/page/<int:page>'], type="http", auth="user", website=True) def customer_kanban(self, page=1, search=None, **post): domain = [] if search: domain.append(('name', 'ilike', search)) post["search"] = search customer_obj = request.env['res.partner'].sudo().search(domain) total = customer_obj.sudo().search_count([]) pager = request.website.pager( url='/customer', total=total, page=page, step=3, ) offset = pager['offset'] customer_obj = customer_obj[offset: offset + 5] return request.render('my_module.customer_form', {'search': search,'customer_details': customer_obj,'pager': pager, })This is the XML code : the template of customer website :
<template id="customer_form" name="Customers"><t t-call="website.layout"><div><div class="col-md-6"><br/><div><form action="/customer" method="post"><t t-call="website.website_search_box"></t><input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/><div><section><div class="customer_details"><center><h3>Customers</h3></center></div><br/><div class="oe_product_cart_new row" style="overflow: hidden;"><t t-foreach="customer_details" t-as="customers"><div class="col-md-3 col-sm-3 col-xs-12" style="padding:1px 1px 1px 1px;"><div style="border: 1px solid #f0eaea;width: 150px;height: auto;padding: 7% 0% 10% 0%;border-radius: 3px;overflow: hidden;margin-bottom: 44px !important;width: 100%;height: 100%;"><div class="oe_product_image"><center><div style="width:100%;overflow: hidden;"><img t-if="customers.image_1920" t-attf-src="/web/image/res.partner/#{customers.id}/image_1920" class="img oe_product_image" style="padding: 0px; margin: 0px; width:auto; height:100%;"/></div><div style="text-align: left;margin: 10px 15px 3px 15px;"><t t-if="customers.name"><span t-esc="customers.name" style="font-weight: bolder;color: #3e3b3b;"/><br/></t></div></center></div></div></div></t></div><div class="products_pager form-inline justify-content-center mt-3"><t t-call="website.pager"><t t-set="_classes">mt-2 ml-md-2</t></t></div></section><br/><hr class="border-600 s_hr_1px w-100 mx-auto s_hr_dotted"/></div></form></div></div></div></t></template>Any help please?Thanks.