from openerp import http
from openerp.http import request

from openerp.addons.website_sale.controllers.main import website_sale


class controller(website_sale):

    @http.route(['/shop/confirm_order'], type='http', auth="public", website=True)
    def confirm_order(self, **post):
        res = super(controller, self).confirm_order(**post)

        order = request.website.sale_get_order(context=request.context)
        if not all([
                line.product_uom_qty <= line.product_id.virtual_available
                for line in order.order_line
        ]):
            return request.redirect("/shop/cart")
        return res

from openerp import http
from openerp.http import request

from openerp.addons.website_sale.controllers.main import website_sale


class controller(website_sale):

    @http.route(['/shop/confirm_order'], type='http', auth="public", website=True)
    def confirm_order(self, **post):
        res = super(controller, self).confirm_order(**post)

        order = request.website.sale_get_order(context=request.context)
        if not all([
                line.product_uom_qty <= line.product_id.virtual_available
                for line in order.order_line if not line.is_delivery
        ]):
            return request.redirect("/shop/cart")
        return res

FIX sale_available integration with delivery
FIX sale_available integration with delivery

  from openerp import http
  from openerp.http import request
  
  from openerp.addons.website_sale.controllers.main import website_sale
  
  
  class controller(website_sale):
  
      @http.route(['/shop/confirm_order'], type='http', auth="public", website=True)
      def confirm_order(self, **post):
          res = super(controller, self).confirm_order(**post)
  
          order = request.website.sale_get_order(context=request.context)
          if not all([
                  line.product_uom_qty <= line.product_id.virtual_available
-                 for line in order.order_line
+                 for line in order.order_line if not line.is_delivery
          ]):
              return request.redirect("/shop/cart")
          return res
  
FIX sale_available integration with delivery
## Code Before:
from openerp import http
from openerp.http import request

from openerp.addons.website_sale.controllers.main import website_sale


class controller(website_sale):

    @http.route(['/shop/confirm_order'], type='http', auth="public", website=True)
    def confirm_order(self, **post):
        res = super(controller, self).confirm_order(**post)

        order = request.website.sale_get_order(context=request.context)
        if not all([
                line.product_uom_qty <= line.product_id.virtual_available
                for line in order.order_line
        ]):
            return request.redirect("/shop/cart")
        return res

## Instruction:
FIX sale_available integration with delivery
## Code After:
from openerp import http
from openerp.http import request

from openerp.addons.website_sale.controllers.main import website_sale


class controller(website_sale):

    @http.route(['/shop/confirm_order'], type='http', auth="public", website=True)
    def confirm_order(self, **post):
        res = super(controller, self).confirm_order(**post)

        order = request.website.sale_get_order(context=request.context)
        if not all([
                line.product_uom_qty <= line.product_id.virtual_available
                for line in order.order_line if not line.is_delivery
        ]):
            return request.redirect("/shop/cart")
        return res
