diff --git a/addons/dine360_theme_chennora/views/checkout_address.xml b/addons/dine360_theme_chennora/views/checkout_address.xml index f5ca122..27b79b9 100644 --- a/addons/dine360_theme_chennora/views/checkout_address.xml +++ b/addons/dine360_theme_chennora/views/checkout_address.xml @@ -432,6 +432,7 @@ params: { address_data: addressData } }) }).then(r => r.json()).then(data => { + console.log("Uber Quote Result:", data.result); if (data.result && data.result.success) { enableButton(); if (errorDiv) errorDiv.classList.add('d-none'); diff --git a/addons/dine360_uber/models/sale_order.py b/addons/dine360_uber/models/sale_order.py index a6f2427..3b5c6d8 100644 --- a/addons/dine360_uber/models/sale_order.py +++ b/addons/dine360_uber/models/sale_order.py @@ -1,32 +1,49 @@ from odoo import models, fields, api, _ +import logging + +_logger = logging.getLogger(__name__) class SaleOrder(models.Model): _inherit = 'sale.order' def _add_uber_delivery_fee(self, amount): """Add the delivery fee as a line item if not already added or update it""" + _logger.info("Uber: Adding delivery fee %s to order %s", amount, self.name) config = self.env['uber.config'].sudo().search([('active', '=', True)], limit=1) if config and config.delivery_product_id: fee_product = config.delivery_product_id - # Ensure product is published so website_sale doesn't remove it from cart - if not fee_product.website_published: - fee_product.sudo().write({'website_published': True}) + + # Ensure product is published and sellable + if not fee_product.website_published or not fee_product.sale_ok: + _logger.info("Uber: Publishing and enabling sale for product %s", fee_product.name) + fee_product.sudo().write({ + 'website_published': True, + 'sale_ok': True + }) - # Set fulfillment type on order + # Set fulfillment type on order if field exists if hasattr(self, 'fulfilment_type'): self.write({'fulfilment_type': 'delivery'}) fee_line = self.order_line.filtered(lambda l: l.product_id.id == fee_product.id) if fee_line: + _logger.info("Uber: Updating existing fee line %s", fee_line.id) fee_line.write({ 'price_unit': amount, 'name': 'Uber Delivery Fee' }) else: + _logger.info("Uber: Creating new fee line for product %s", fee_product.id) self.write({'order_line': [(0, 0, { 'product_id': fee_product.id, 'name': 'Uber Delivery Fee', 'price_unit': amount, 'product_uom_qty': 1, })]}) + + # Recalculate taxes and totals + self._amount_all() + else: + _logger.warning("Uber: Config or delivery product not found") + return True