Passa al contenuto
Odoo Menu
  • Accedi
  • Provalo gratis
  • App
    Finanze
    • Contabilità
    • Fatturazione
    • Note spese
    • Fogli di calcolo (BI)
    • Documenti
    • Firma
    Vendite
    • CRM
    • Vendite
    • Punto vendita Negozio
    • Punto vendita Ristorante
    • Abbonamenti
    • Noleggi
    Siti web
    • Configuratore sito web
    • E-commerce
    • Blog
    • Forum
    • Live chat
    • E-learning
    Supply chain
    • Magazzino
    • Produzione
    • PLM
    • Acquisti
    • Manutenzione
    • Qualità
    Risorse umane
    • Dipendenti
    • Assunzioni
    • Ferie
    • Valutazioni
    • Referral dipendenti
    • Parco veicoli
    Marketing
    • Social marketing
    • E-mail marketing
    • SMS marketing
    • Eventi
    • Marketing automation
    • Sondaggi
    Servizi
    • Progetti
    • Fogli ore
    • Assistenza sul campo
    • Helpdesk
    • Pianificazione
    • Appuntamenti
    Produttività
    • Comunicazioni
    • Approvazioni
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    App di terze parti Odoo Studio Piattaforma cloud Odoo
  • Settori
    Retail
    • Libreria
    • Negozio di abbigliamento
    • Negozio di arredamento
    • Alimentari
    • Ferramenta
    • Negozio di giocattoli
    Cibo e ospitalità
    • Bar e pub
    • Ristorante
    • Fast food
    • Pensione
    • Grossista di bevande
    • Hotel
    Agenzia immobiliare
    • Agenzia immobiliare
    • Studio di architettura
    • Edilizia
    • Gestione immobiliare
    • Impresa di giardinaggio
    • Associazione di proprietari immobiliari
    Consulenza
    • Società di contabilità
    • Partner Odoo
    • Agenzia di marketing
    • Studio legale
    • Selezione del personale
    • Audit e certificazione
    Produzione
    • Tessile
    • Metallo
    • Arredamenti
    • Alimentare
    • Birrificio
    • Ditta di regalistica aziendale
    Benessere e sport
    • Club sportivo
    • Negozio di ottica
    • Centro fitness
    • Centro benessere
    • Farmacia
    • Parrucchiere
    Commercio
    • Tuttofare
    • Hardware e assistenza IT
    • Ditta di installazione di pannelli solari
    • Calzolaio
    • Servizi di pulizia
    • Servizi di climatizzazione
    Altro
    • Organizzazione non profit
    • Ente per la tutela ambientale
    • Agenzia di cartellonistica pubblicitaria
    • Studio fotografico
    • Punto noleggio di biciclette
    • Rivenditore di software
    Carica tutti i settori
  • Community
    Apprendimento
    • Tutorial
    • Documentazione
    • Certificazioni 
    • Formazione
    • Blog
    • Podcast
    Potenzia la tua formazione
    • Programma educativo
    • Scale Up! Business Game
    • Visita Odoo
    Ottieni il software
    • Scarica
    • Versioni a confronto
    • Note di versione
    Collabora
    • Github
    • Forum
    • Eventi
    • Traduzioni
    • Diventa nostro partner
    • Servizi per partner
    • Registra la tua società di contabilità
    Ottieni servizi
    • Trova un partner
    • Trova un contabile
    • Incontra un esperto
    • Servizi di implementazione
    • Testimonianze dei clienti
    • Supporto
    • Aggiornamenti
    GitHub Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Richiedi una demo
  • Prezzi
  • Aiuto

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

  • CRM
  • e-Commerce
  • Contabilità
  • Magazzino
  • PoS
  • Progetti
  • MRP
All apps
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
Assistenza

How to avoid sale order automaticaly created for public user in the website shop?

Iscriviti

Ricevi una notifica quando c'è un'attività per questo post

La domanda è stata contrassegnata
shopnginxurlsitemaprobots.txt
2 Risposte
12064 Visualizzazioni
Avatar
Pascal Tremblay

Hello there,

We have a site on Odoo 8. The shop works well at http://cferalma.com/shop. 

But it is only a catalog. Users can't buy on this site. No "add to cart" button, nowhere.

But sometimes (often), sale order are created for the public user in the sales. We don't want these sale orders.

I will publish below our solution for this problem. May be it could help somebody.

Thanks to comment.

0
Avatar
Abbandona
Avatar
Pascal Tremblay
Autore Risposta migliore

Here is our solution. We hope it could help somebody.

I hope you could comment this solution! May be we are not right.


Comment

Since there is no link for these 6 links on our website, we want they become inaccessible, even if they are written directly in browser address bar :

/shop/cart

/shop/payment/validate

/shop/confirm_order

/shop/confirmation

/shop/payment

/shop/checkout

We are pretty sure that this is the problem for all those sale orders automatically created. So we don't want those links appear in search engine. More, we also don't want those links work at all if the user write it in directly in his browser address bar.


First move : modify the robots.txt file

In a custom module, we put this code :

<?xml version="1.0" encoding="UTF-8"?>
<openerp>

<template id="website.robots">

User-agent: *

Disallow: /shop/cart

Disallow: /shop/payment/validate

Disallow: /shop/confirm_order

Disallow: /shop/confirmation

Disallow: /shop/payment

Disallow: /shop/checkout

Sitemap:<t t-esc="url_root"/>sitemap.xml

</template>

</data>

</openerp>



Second move : modify the sitemap.xml

We override the enumerate_pages method of the website class :

import logging

logger = logging.getLogger(__name__)

from openerp.osv import osv

from openerp.addons.web.http import request

class website(osv.osv):

_inherit = "website"

def enumerate_pages(self, cr, uid, ids, query_string=None, context=None):

logger.error("enumerate_pages BEGIN")

""" Available pages in the website/CMS. This is mostly used for links

generation and can be overridden by modules setting up new HTML

controllers for dynamic pages (e.g. blog).

By default, returns template views marked as pages.

:param str query_string: a (user-provided) string, fetches pages

matching the string

:returns: a list of mappings with two keys: ``name`` is the displayable

name of the resource (page), ``url`` is the absolute URL

of the same.

:rtype: list({name: str, url: str})

"""

router = request.httprequest.app.get_db_router(request.db)

# Force enumeration to be performed as public user

url_list = []

for rule in router.iter_rules():

if not self.rule_is_enumerable(rule):

continue

converters = rule._converters or {}

if query_string and not converters and (query_string not in rule.build([{}], append_unknown=False)[1]):

continue

values = [{}]

convitems = converters.items()

# converters with a domain are processed after the other ones

gd = lambda x: hasattr(x[1], 'domain') and (x[1].domain <> '[]')

convitems.sort(lambda x, y: cmp(gd(x), gd(y)))

for (i,(name, converter)) in enumerate(convitems):

newval = []

for val in values:

query = i==(len(convitems)-1) and query_string

for v in converter.generate(request.cr, uid, query=query, args=val, context=context):

newval.append( val.copy() )

v[name] = v['loc']

del v['loc']

newval[-1].update(v)

values = newval

logger.error(" values :: %s", str(values))

for value in values:

domain_part, url = rule.build(value, append_unknown=False)

page = {'loc': url}

for key,val in value.items():

if key.startswith('__'):

page[key[2:]] = val

 

if url in ('/sitemap.xml','/shop/cart','/shop/payment','/shop/payment/validate','/shop/confirm_order','/shop/confirmation','/shop/checkout',):

logger.error(" this url was avoid : %s",str(url))

continue

if url in url_list:

continue

url_list.append(url)

logger.error(" page :: %s", str(page))

yield page



Third move : redirect url in nginx

upstream odoo-cfer {

server 127.0.0.1:8077;

}

server {

listen 80;

server_name cferalma.com;

location / {

proxy_pass http://odoo-cfer;

proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;

proxy_redirect off;

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header X-Forwarded-Proto https;

}

location ~* /web/static/ {

proxy_cache_valid 200 60m;

proxy_buffering on;

expires 864000;

proxy_pass http://odoo-cfer;

}

location = /shop/cart {

return 301 http://cferalma.com/shop;

}

location = /shop/payment/validate {

return 301 http://cferalma.com/shop;

}

location = /shop/confirm_order {

return 301 http://cferalma.com/shop;

}

location = /shop/confirmation {

return 301 http://cferalma.com/shop;

}

location = /shop/payment {

return 301 http://cferalma.com/shop;

}

location = /shop/checkout {

return 301 http://cferalma.com/shop;

}

error_page 502 /502.html;

location = /502.html {

root /usr/share/nginx/html;

}

}



2
Avatar
Abbandona
Avatar
Fatih Piristine
Risposta migliore

rewriting the controller in a custom module would be way handier. no need to bubble up the webserver conf.

also adding a column to website model would make easier to configure for later use of excluding things from sitemaps.

class website(osv.osv):
_inherit = 'website'

_columns = {
'google_tags_manager_key': fields.char('Google Tags Manager'),
'exclude_from_sitemap': fields.text('Exclude from sitemap')
}


def enumerate_pages ( ... )
...
    exclude_from_sitemap = []

    if current_website.exclude_from_sitemap:
    exclude_from_sitemap = current_website.exclude_from_sitemap.splitlines()
...


...
if url in ('/sitemap.xml',) or url in exclude_from_sitemap:
continue
if url in url_list:
continue
if not published:
continue
url_list.append(url)

yield page


1
Avatar
Abbandona
Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!

Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!

Registrati
Post correlati Risposte Visualizzazioni Attività
Google can't fetch Odoo robots.txt (Failed: Robots.txt unreachable) Risolto
google sitemap robots.txt
Avatar
1
apr 23
4862
Urls are not showing in HTTPs version
website sitemap robots.txt
Avatar
Avatar
1
gen 23
4713
Setting URL for access to Odoo
nginx url v14
Avatar
Avatar
1
giu 21
8659
direct url shop of a base Risolto
shop url direct
Avatar
Avatar
2
nov 20
4484
How to avoid wrong domain in my sitemap.xml? Risolto
domain url sitemap
Avatar
1
dic 16
8776
Community
  • Tutorial
  • Documentazione
  • Forum
Open source
  • Scarica
  • Github
  • Runbot
  • Traduzioni
Servizi
  • Hosting Odoo.sh
  • Supporto
  • Aggiornamenti
  • Sviluppi personalizzati
  • Formazione
  • Trova un contabile
  • Trova un partner
  • Diventa nostro partner
Chi siamo
  • La nostra azienda
  • Branding
  • Contattaci
  • Lavora con noi
  • Eventi
  • Podcast
  • Blog
  • Clienti
  • Note legali • Privacy
  • Sicurezza
الْعَرَبيّة 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 è un gestionale di applicazioni aziendali open source pensato per coprire tutte le esigenze della tua azienda: CRM, Vendite, E-commerce, Magazzino, Produzione, Fatturazione elettronica, Project Management e molto altro.

Il punto di forza di Odoo è quello di offrire un ecosistema unico di app facili da usare, intuitive e completamente integrate tra loro.

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