# -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. from odoo import http from odoo.http import request from odoo.addons.website_sale.controllers.main import WebsiteSale class WebsiteSaleDelivery(WebsiteSale): @http.route(['/shop/payment'], type='http', auth="public", website=True) def payment(self, **post): order = request.website.sale_get_order() carrier_id = post.get('carrier_id') if carrier_id: carrier_id = int(carrier_id) if order: order._check_carrier_quotation(force_carrier_id=carrier_id) if carrier_id: return request.redirect("/shop/payment") return super(WebsiteSaleDelivery, self).payment(**post) def order_lines_2_google_api(self, order_lines): """ Transforms a list of order lines into a dict for google analytics """ order_lines_not_delivery = order_lines.filtered(lambda line: not line.is_delivery) return super(WebsiteSaleDelivery, self).order_lines_2_google_api(order_lines_not_delivery) def order_2_return_dict(self, order): """ Returns the tracking_cart dict of the order for Google analytics """ ret = super(WebsiteSaleDelivery, self).order_2_return_dict(order) for line in order.order_line: if line.is_delivery: ret['transaction']['shipping'] = line.price_unit return ret