fix: align peer_bus signature, bot presence SQL, XML-RPC timeout

- All specialist agents: handle_peer_request(request_type, params, directive_id)
  replaces handle_peer_request(request: dict) so callers pass structured args
- ab_ai_bot: force-write bus_presence.status via SQL so Odoo 18 WebSocket presence
  shows the correct colour immediately (ORM compute does not trigger on last_poll writes)
- odoo_client: wrap XML-RPC executor calls in asyncio.wait_for to enforce timeout

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-19 23:02:51 -04:00
parent 93f2a101fa
commit 233f461480
9 changed files with 69 additions and 59 deletions

View File

@@ -283,30 +283,29 @@ class FinanceAgent(BaseAgent):
# ------------------------------------------------------------------
# Peer bus handler
# ------------------------------------------------------------------
async def handle_peer_request(self, request: dict) -> dict:
req_type = request.get('type', '')
async def handle_peer_request(self, request_type: str, params: dict, directive_id: str) -> dict:
try:
if req_type == 'overdue_summary':
partner_id = request.get('partner_id')
if request_type == 'overdue_summary':
partner_id = params.get('partner_id')
kwargs = {}
if partner_id:
kwargs['partner_id'] = partner_id
overdue = await self._ft.get_overdue_invoices(**kwargs)
total = sum(inv.get('amount_residual', 0) for inv in overdue)
return {'overdue_count': len(overdue), 'overdue_total': total, 'invoices': overdue}
if req_type == 'payment_history':
partner_id = request.get('partner_id')
if request_type == 'payment_history':
partner_id = params.get('partner_id')
if not partner_id:
return {'error': 'partner_id required'}
history = await self._ft.get_payment_history(partner_id=partner_id)
return {'history': history}
if req_type == 'financial_summary':
period = request.get('period', 'this_month')
if request_type == 'financial_summary':
period = params.get('period', 'this_month')
summary = await self._ft.get_financial_summary(period=period)
return {'summary': summary}
return {'error': f'Unknown peer request type: {req_type}'}
return {'error': f'Unknown peer request type: {request_type}'}
except Exception as exc:
logger.error('handle_peer_request failed type=%s: %s', req_type, exc)
logger.error('handle_peer_request failed type=%s: %s', request_type, exc)
return {'error': str(exc)}
# ------------------------------------------------------------------