Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

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

Odoberať

Get notified when there's activity on this post

This question has been flagged
shopproductpreviousnextnavigation
2 Replies
8334 Zobrazenia
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
Zrušiť
Pascal Tremblay
Autor

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

Avatar
Pascal Tremblay
Autor 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
Zrušiť
Enjoying the discussion? Don't just read, join in!

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

Registrácia
Related Posts Replies Zobrazenia Aktivita
Select products with 3 shops on the same database (V18)
shop product
Avatar
0
okt 25
528
Shop by Cities or Countries on Webpage
shop product
Avatar
0
apr 16
3526
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
291
Customise the display of prices on the main page in online store
shop product price
Avatar
0
nov 24
1654
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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