Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

How could I add "previouS" and "next" button in my products page?

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
shopproductpreviousnextnavigation
2 Réponses
8308 Vues
Avatar
Pascal Tremblay

Hello all,

our shop is great on odoo 8.  All works very well!  

But once in a product page, how could we add a previous and next button to allow navigation in the products pages?

thansk for your tip!

0
Avatar
Ignorer
Pascal Tremblay
Auteur

A little up here!!!! Somebody would have a solution already for this?

Avatar
Pascal Tremblay
Auteur Meilleure réponse

Here is our solution to get those two buttons on a product page. With those buttons, you can navigate through all the products of the active selected category. Buttons becomes disabled when no product before or after in the category.


Result :




Template :

<template id="website.previous_and_next" name="Previous and next">

<div id="previous_and_next_iv" t-if="pager_pt['products_count'] > 1">

<a

t-att-class=" 'btn btn-primary pull-left mt10 mb10 disabled' if pager_pt['product']['num'] == 0 else 'btn btn-primary pull-left mt10 mb10' "

t-att-href="pager_pt['product_previous']['url']" >

Previous product in this category</a>

<a

t-att-class=" 'btn btn-primary pull-right mt10 mb10 disabled' if pager_pt['product']['num'] == pager_pt['products_count'] else 'btn btn-primary pull-right mt10 mb10' "

t-att-href="pager_pt['product_next']['url']" >

Next product in this category</a>

</div>

</template>



Where you want to put the buttons :

<template id="website_sale.product" name="Product">

<t t-call="website.layout">

[...]

<div class="row previous_and_next_iv">

<t t-call="website.previous_and_next" />

</div>

[...]

</template>



Python code to override :


class website_sale_all(website_sale):

@http.route(['/shop/product/<model("product.template"):product>'], type='http', auth="public", website=True)

def product(self, product, category='', search='', **kwargs):

cr, uid, context, pool = request.cr, request.uid, request.context, request.registry

category_obj = pool['product.public.category']

template_obj = pool['product.template']

context.update(active_id=product.id)

if category:

category = category_obj.browse(cr, uid, int(category), context=context)

category = category if category.exists() else False

attrib_list = request.httprequest.args.getlist('attrib')

attrib_values = [map(int,v.split("-")) for v in attrib_list if v]

attrib_set = set([v[1] for v in attrib_values])

keep = QueryURL('/shop', category=category and category.id, search=search, attrib=attrib_list)

category_ids = category_obj.search(cr, uid, [], context=context)

category_list = category_obj.name_get(cr, uid, category_ids, context=context)

category_list = sorted(category_list, key=lambda category: category[1])

pricelist = self.get_pricelist()

from_currency = pool.get('product.price.type')._get_field_currency(cr, uid, 'list_price', context)

to_currency = pricelist.currency_id

compute_currency = lambda price: pool['res.currency']._compute(cr, uid, from_currency, to_currency, price, context=context)

domain = self._get_search_domain(search, category, attrib_values)

url = "/shop/product"

product_obj = pool.get('product.template')

product_count = product_obj.search_count(cr, uid, domain, context=context)

product_ids = product_obj.search(cr, uid, domain, limit=200, order='website_published desc, website_sequence desc', context=context)

if category:

cat_id = category.id

else:

cat_id = ''

pager_pt = request.website.pager_pt(active_product=product.id, products=product_ids, active_category=cat_id)

products = product_obj.browse(cr, uid, product_ids, context=context)

if not context.get('pricelist'):

context['pricelist'] = int(self.get_pricelist())

product = template_obj.browse(cr, uid, int(product), context=context)

values = {

'search': search,

'category': category,

'pager_pt': pager_pt,

'pricelist': pricelist,

'attrib_values': attrib_values,

'compute_currency': compute_currency,

'attrib_set': attrib_set,

'keep': keep,

'category_list': category_list,

'main_object': product,

'product': product,

'get_attribute_value_ids': self.get_attribute_value_ids

}

return request.website.render("website_sale.product", values)


from openerp.addons.website.models.website import website

class website_iv(osv.osv):

_inherit = "website"

def pager_pt(self, cr, uid, active_product, products, active_category, context=None):

products_count = len(products)

num_product = products.index(active_product)

num_previous = num_product - 1

num_next = num_product + 1

num_min = 0

num_max = products_count - 1

def get_url(id):

if active_category:

_url = "/shop/product/%s?category=%s" % (id, active_category) #if page > 1 else url

else:

_url = "/shop/product/%s" % (id)

return _url

retour = {

"products_count": products_count - 1,

"product": {

#'url': 'asdfasdF', #get_url(active_product),

'num': num_product

},

"product_previous": {

'url': get_url(products[max(num_previous, num_min)]),

'num': num_previous

},

"product_next": {

'url': get_url(products[min(num_next, num_max)]),

'num': num_next

},

}

return retour



4
Avatar
Ignorer
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
Select products with 3 shops on the same database (V18)
shop product
Avatar
0
oct. 25
522
Shop by Cities or Countries on Webpage
shop product
Avatar
0
avr. 16
3520
403: Forbidden The page you were looking for could not be authorized.
shop product
Avatar
Avatar
1
mars 15
1012
Price list by packaging
configuration shop product
Avatar
Avatar
Avatar
2
nov. 25
261
Customise the display of prices on the main page in online store
shop product price
Avatar
0
nov. 24
1644
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now