implement Uber delivery fee integration, add online order management for POS, and update Docker configuration.

This commit is contained in:
Alaguraj0361 2026-04-10 18:41:16 +05:30
parent 696e4045a2
commit c730b5c95d
3 changed files with 6 additions and 36 deletions

View File

@ -45,17 +45,12 @@ class PosOrder(models.Model):
self.ensure_one()
self.write({'online_order_status': 'confirmed'})
# If it's an online order with an online payment, mark as paid in POS to avoid confusion
is_paid_online = self.sale_order_id.payment_option == 'online_gateway'
if not is_paid_online and self.sale_order_id:
successful_txs = self.sale_order_id.transaction_ids.filtered(lambda tx: tx.state in ['authorized', 'done'])
if successful_txs and sum(successful_txs.mapped('amount')) >= self.sale_order_id.amount_total:
is_paid_online = True
if self.is_online_order and self.sale_order_id and is_paid_online:
# If it's an online order with an online payment option, mark as paid in POS to avoid confusion
if self.is_online_order and self.sale_order_id and self.sale_order_id.payment_option == 'online_gateway':
# Check if it needs payment (not yet paid in POS)
if self.state == 'draft' and self.amount_total > 0 and self.amount_paid < self.amount_total:
# Find a suitable payment method (Online Payment or Stripe)
# We prioritize methods linked to the current POS config
payment_method = self._get_online_payment_method()
if payment_method:

View File

@ -112,19 +112,11 @@ class SaleOrderOnline(models.Model):
# Link back to sale order
sale_order.write({'pos_order_id': pos_order.id})
# Check if order is already paid online (e.g. Stripe, PayPal, etc.)
# We check both the custom payment_option and Odoo's standard transactions
is_paid_online = sale_order.payment_option == 'online_gateway'
if not is_paid_online:
# Check for successful transactions (authorize or done)
successful_txs = sale_order.transaction_ids.filtered(lambda tx: tx.state in ['authorized', 'done'])
if successful_txs and sum(successful_txs.mapped('amount')) >= sale_order.amount_total:
is_paid_online = True
if is_paid_online and sale_order.amount_total > 0:
# If paid online via gateway, record payment in POS immediately
if sale_order.payment_option == 'online_gateway' and sale_order.amount_total > 0:
payment_method = pos_order._get_online_payment_method()
if payment_method:
_logger.info("Recording confirmed online payment for POS order %s from Sale Order %s", pos_order.name, sale_order.name)
_logger.info("Recording online payment for POS order %s from Sale Order %s", pos_order.name, sale_order.name)
pos_order.env['pos.payment'].create({
'amount': sale_order.amount_total,
'payment_date': fields.Datetime.now(),
@ -132,12 +124,7 @@ class SaleOrderOnline(models.Model):
'pos_order_id': pos_order.id,
})
# Process as paid so the state changes and payment button disappears
# We use a delayed call or ensure state is updated
pos_order.action_pos_order_paid()
# Also set the online status to confirmed since it's paid
pos_order.write({'online_order_status': 'confirmed'})
else:
_logger.warning("No suitable POS Payment Method for paid online order %s", pos_order.name)
# Set all lines to a "hold" state - they will go to KDS only when cashier confirms
for line in pos_order.lines:

View File

@ -14,18 +14,6 @@ class SaleOrder(models.Model):
carriers |= self.carrier_id
return carriers
def _remove_delivery_line(self):
"""Prevent Odoo from automatically removing the Uber delivery fee during checkout transitions"""
if self.carrier_id and 'Uber' in (self.carrier_id.name or ''):
return
return super()._remove_delivery_line()
def _check_carrier_quotation(self, force_carrier_id=None, **kwargs):
"""Skip delivery re-validation for Uber orders to prevent the fee from being cleared"""
if self.carrier_id and 'Uber' in (self.carrier_id.name or ''):
return True
return super()._check_carrier_quotation(force_carrier_id=force_carrier_id, **kwargs)
def _add_uber_delivery_fee(self, amount):
"""Add the delivery fee using Odoo's standard delivery system to satisfy checkout validation"""
_logger.info("Uber: Syncing delivery fee %s to order %s", amount, self.name)