<commit_before># -*- coding: utf-8 -*-
import werkzeug
import logging
import pprint
from urlparse import urlparse, parse_qs
from openerp import SUPERUSER_ID
from openerp import http
from openerp.http import request
from openerp.tools.translate import _
from openerp.addons.website.models.website import slug
import openerp.addons.web.controllers.main
import openerp.addons.website_sale.controllers.main

_logger = logging.getLogger(__name__)

class website_sale(openerp.addons.website_sale.controllers.main.website_sale):

    def check_cart(self):
        order = request.website.sale_get_order()
        valid = True
        if order:
            companies = [1]
            for order_line in order.order_line:
                company = order_line.product_id.company_id.id
                if not company in companies:
                    companies.append(company)
            if len(companies) > 2:
                logging.debug("Más de dos compañias detectadas, muestra el aviso") 
                valid = False
        else:
            valid = False
        return valid

    # Set Valid/invalid flag to show/hide warning
    @http.route(['/shop/cart'], type='http', auth="public", website=True)
    def cart(self, **post):
        valid = self.check_cart()
        order = request.website.sale_get_order()
        values = {
          'website_sale_order': order,
          'valid':valid,
        }
        return request.render("website_sale.cart", values)

    #------------------------------------------------------
    # Checkout
    # No acepta productos de distintas tiendas, retorna al carro 
    # Esto es necessario para no bloquear las ordenes a las tiendas que no hayan configurado metodo de envio
    #------------------------------------------------------
    @http.route(['/shop/checkout'], type='http', auth="public", website=True)
    def checkout(self, **post):
        if self.check_cart():
            cr, uid, context = request.cr, request.uid, request.context
            context['send_email'] = False
            return super(website_sale, self).checkout(**post)
        else:
            return request.redirect("/shop/cart")

<commit_msg>Fix invalid message when the cart is empty<commit_after># -*- coding: utf-8 -*-
import werkzeug
import logging
import pprint
from urlparse import urlparse, parse_qs
from openerp import SUPERUSER_ID
from openerp import http
from openerp.http import request
from openerp.tools.translate import _
from openerp.addons.website.models.website import slug
import openerp.addons.web.controllers.main
import openerp.addons.website_sale.controllers.main

_logger = logging.getLogger(__name__)

class website_sale(openerp.addons.website_sale.controllers.main.website_sale):

    def check_cart(self):
        order = request.website.sale_get_order()
        valid = True
        if order:
            companies = [1]
            for order_line in order.order_line:
                company = order_line.product_id.company_id.id
                if not company in companies:
                    companies.append(company)
            if len(companies) > 2:
                logging.debug("Más de dos compañias detectadas, muestra el aviso") 
                valid = False
        return valid

    # Set Valid/invalid flag to show/hide warning
    @http.route(['/shop/cart'], type='http', auth="public", website=True)
    def cart(self, **post):
        valid = self.check_cart()
        order = request.website.sale_get_order()
        values = {
          'website_sale_order': order,
          'valid':valid,
        }
        return request.render("website_sale.cart", values)

    #------------------------------------------------------
    # Checkout
    # No acepta productos de distintas tiendas, retorna al carro 
    # Esto es necessario para no bloquear las ordenes a las tiendas que no hayan configurado metodo de envio
    #------------------------------------------------------
    @http.route(['/shop/checkout'], type='http', auth="public", website=True)
    def checkout(self, **post):
        if self.check_cart():
            cr, uid, context = request.cr, request.uid, request.context
            context['send_email'] = False
            return super(website_sale, self).checkout(**post)
        else:
            return request.redirect("/shop/cart")


{'fraction_non_alphanumeric': 0.14057803468208094, 'fraction_numerical': 0.0013872832369942196, 'mean_word_length': 2.166910688140556, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2214821', 'n_tokens_mistral': 1243, 'n_tokens_neox': 1163, 'n_words': 316}