Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Aplikacije
    Finance
    • Knjigovodstvo
    • Obračun
    • Stroški
    • Spreadsheet (BI)
    • Dokumenti
    • Podpisovanje
    Prodaja
    • CRM
    • Prodaja
    • POS Shop
    • POS Restaurant
    • Naročnine
    • Najem
    Spletne strani
    • Website Builder
    • Spletna trgovina
    • Blog
    • Forum
    • Pogovor v živo
    • eUčenje
    Dobavna veriga
    • Zaloga
    • Proizvodnja
    • PLM
    • Nabava
    • Vzdrževanje
    • Kakovost
    Kadri
    • Kadri
    • Kadrovanje
    • Odsotnost
    • Ocenjevanja
    • Priporočila
    • Vozni park
    Marketing
    • Družbeno Trženje
    • Email Marketing
    • SMS Marketing
    • Dogodki
    • Avtomatizacija trženja
    • Ankete
    Storitve
    • Projekt
    • Časovnice
    • Storitve na terenu
    • Služba za pomoč
    • Načrtovanje
    • Termini
    Produktivnost
    • Razprave
    • Odobritve
    • IoT
    • Voip
    • Znanje
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industrije
    Trgovina na drobno
    • Book Store
    • Trgovina z oblačili
    • Trgovina s pohištvom
    • Grocery Store
    • Trgovina s strojno opremo računalnikov
    • Trgovina z igračami
    Food & Hospitality
    • Bar and Pub
    • Restavracija
    • Hitra hrana
    • Guest House
    • Beverage Distributor
    • Hotel
    Nepremičnine
    • Real Estate Agency
    • Arhitekturno podjetje
    • Gradbeništvo
    • Estate Management
    • Vrtnarjenje
    • Združenje lastnikov nepremičnin
    Svetovanje
    • Računovodsko podjetje
    • Odoo Partner
    • Marketinška agencija
    • Law firm
    • Pridobivanje talentov
    • Audit & Certification
    Proizvodnja
    • Tekstil
    • Metal
    • Pohištvo
    • Hrana
    • Brewery
    • Poslovna darila
    Health & Fitness
    • Športni klub
    • Trgovina z očali
    • Fitnes center
    • Wellness Practitioners
    • Lekarna
    • Frizerski salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Sistemi sončne energije
    • Izdelovalec čevljev
    • Čistilne storitve
    • HVAC Services
    Ostali
    • Neprofitna organizacija
    • Agencija za okolje
    • Najem oglasnih panojev
    • Fotografija
    • Najem koles
    • Prodajalec programske opreme
    Browse all Industries
  • Skupnost
    Learn
    • Tutorials
    • Dokumentacija
    • Certifikati
    • Šolanje
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Prenesi
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Dogodki
    • Prevodi
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Sklici kupca
    • Podpora
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Določanje cen
  • Pomoč

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

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

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

Naroči se

Get notified when there's activity on this post

This question has been flagged
shopproductpreviousnextnavigation
2 Odgovori
8325 Prikazi
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
Opusti
Pascal Tremblay
Avtor

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

Avatar
Pascal Tremblay
Avtor Best Answer

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
Opusti
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Prijavi
Related Posts Odgovori Prikazi Aktivnost
Select products with 3 shops on the same database (V18)
shop product
Avatar
0
okt. 25
524
Shop by Cities or Countries on Webpage
shop product
Avatar
0
apr. 16
3521
403: Forbidden The page you were looking for could not be authorized.
shop product
Avatar
Avatar
1
mar. 15
1012
Price list by packaging
configuration shop product
Avatar
Avatar
Avatar
2
nov. 25
271
Customise the display of prices on the main page in online store
shop product price
Avatar
0
nov. 24
1645
Community
  • Tutorials
  • Dokumentacija
  • Forum
Open Source
  • Prenesi
  • Github
  • Runbot
  • Prevodi
Services
  • Odoo.sh Hosting
  • Podpora
  • Nadgradnja
  • Custom Developments
  • Izobraževanje
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Sredstva blagovne znamke
  • Kontakt
  • Zaposlitve
  • Dogodki
  • Podcast
  • Blog
  • Stranke
  • Pravno • Zasebnost
  • Varnost
الْعَرَبيّة 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 is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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