Ir al contenido
Odoo Menú
  • Iniciar sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de bienes inmuebles
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Odoo Community
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita una demostración
  • Precios
  • Ayuda

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

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyectos
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

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

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
shopnginxurlsitemaprobots.txt
2 Respuestas
12039 Vistas
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
Descartar
Avatar
Pascal Tremblay
Autor Mejor respuesta

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
Descartar
Avatar
Fatih Piristine
Mejor respuesta

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
Descartar
¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Registrarse
Publicaciones relacionadas Respuestas Vistas Actividad
Google can't fetch Odoo robots.txt (Failed: Robots.txt unreachable) Resuelto
google sitemap robots.txt
Avatar
1
abr 23
4858
Urls are not showing in HTTPs version
website sitemap robots.txt
Avatar
Avatar
1
ene 23
4708
Setting URL for access to Odoo
nginx url v14
Avatar
Avatar
1
jun 21
8657
direct url shop of a base Resuelto
shop url direct
Avatar
Avatar
2
nov 20
4479
How to avoid wrong domain in my sitemap.xml? Resuelto
domain url sitemap
Avatar
1
dic 16
8773
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidad
  • Seguridad
الْعَرَبيّة 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 es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y estar totalmente integrado.

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