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

hi, i want to limit  display to 15 items, but i don't know how to create pagination in order to show all the rest of the records.

controllers.py : 

@http.route('/coopaname_helpdesk/liste_offres', type ='http', auth='public', website=True)
def liste_offres(self):

tickets = request.env['monmarchepublic'].sudo().search([] ,limit=15)
return http.request.render('coopaname_helpdesk.liste_offres', {'tickets': tickets })

my template.xml : 

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="liste_offres" model="ir.ui.view">
<field name="name">coopaname_helpdesk.marchepublic</field>
<field name="inherit_id" ref="coopaname_helpdesk.marchepublic" />
<field name="mode">primary</field>
<field name="key">coopaname_helpdesk.liste_offres</field>
<field name="arch" type="xml">
<xpath expr="//div" position="after">
<div class="oe_structure" >
<div class="container" >

<t t-foreach="tickets" t-as="ticket">
<div class="col-md-4 col-xs-12 " style="text-align: center; ">
<div class="panel panel-primary">
<div class="panel-heading text-center" style="height:85px;" >
<h3 style="margin: 0" class="o_default_snippet_text"><span t-field="ticket.x_cat"/></h3>
<p style="margin: 0" class="o_default_snippet_text"><span t-field="ticket.x_date_order"/></p>
</div>
<div class="panel-body text-center text-muted" style="background-color: rgba(0,0,0,0.1); width: 350px; height:75px;">
<h3 style="margin: 0">
<b style="font-size: 25px; color: #8EA2C6" class="o_default_snippet_text"><span t-field="ticket.x_objet_consultation"/></b>
</h3>
</div>
<ul class="list-group" >
<li class="list-group-item o_default_snippet_text"><a t-attf-href="/coopaname_helpdesk/annonce/#{ticket.id}">#<t t-esc="ticket.id"/></a></li>
<li class="list-group-item o_default_snippet_text">Statut de l'offre : <span t-field="ticket.x_etape"/></li>
<li class="list-group-item o_default_snippet_text">Pouvoir Adjudicateur : <span t-field="ticket.x_admin"/></li>
<li class="list-group-item o_default_snippet_text">Ville du Pouvoir Adjudicateur: <span t-field="ticket.x_ville_adju"/></li>
<li class="list-group-item o_default_snippet_text">Date limite de dépot de candidature: <span t-field="ticket.x_date_limite"/></li>
</ul>
<div class="panel-footer text-center">
<p class="text-muted">
<i class="o_default_snippet_text"> Publié par : <span t-field="ticket.x_name"/></i>
</p>
<a t-attf-href="/coopaname_helpdesk/annonce/#{ticket.id}" class="btn btn-primary btn-lg o_default_snippet_text">Plus d'information</a>
</div>
</div>
</div>
</t>
</div>
</div>
</xpath>
</field>
</record>
</data>
</odoo>


Avatar
Zrušit
Nejlepší odpověď

Hi Jules,

Odoo provides default feature to manage website pagination. For that you have to render the pager values as below code.

model_ids = request.env[model_name].search([], offset=(page - 1) * 10, limit=10)
total = model_ids.search_count([])
pager = request.website.pager(
            url='url path',
            total=total,
            page=page,
            step=10,
        )

and you have to call website pager template in your custom template. For more information just see how Website sale(Shop) page work in odoo website. You will find solution. The above code is used for shop page.

Hope it will helpful for you.


Thanks and regards

Haresh Kansara

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
bře 15
6933
1
úno 18
3917
2
čvc 25
4471
2
pro 24
7657
2
lis 24
28422