fix: three bugs blocking bot presence and approval UI

1. OdooClient missing self._timeout — every _xmlrpc_call raised
   AttributeError, making the odoo health check permanently fail.
   Fix: set self._timeout = XMLRPC_TIMEOUT in __init__.

2. action_ping only accepted ollama=='ok' but health.py now returns
   'warming' when the model is not yet hot in VRAM. Fix: treat
   warming as passing so the bot goes online and the model loads
   on the first real request.

3. /ai/approval/pending declared methods=['GET'] on a type='json'
   route — Odoo JSON-RPC always POSTs, so every browser call got
   405 METHOD NOT ALLOWED. Fix: change to methods=['POST'].

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Carlos Garcia
2026-05-20 20:53:49 -04:00
parent b23ab77ee9
commit 7a0aad3f37
3 changed files with 10 additions and 2 deletions

View File

@@ -10,7 +10,7 @@ _logger = logging.getLogger(__name__)
class AiApprovalController(http.Controller):
@http.route('/ai/approval/pending', type='json', auth='user', methods=['GET'])
@http.route('/ai/approval/pending', type='json', auth='user', methods=['POST'])
def list_pending(self):
if not request.env.user.has_group('activeblue_ai.group_ai_manager'):
return {'error': 'Access denied', 'items': []}

View File

@@ -72,7 +72,14 @@ class AbAiBot(models.Model):
data = resp.json() if resp.content else {}
# Check every required system individually.
checks = {s: data.get(s) == 'ok' for s in self.REQUIRED_SYSTEMS}
# 'warming' for ollama means the model is loading into VRAM but
# Ollama itself is reachable — treat as passing so the bot goes
# online and the model loads on the first real request.
def _passes(system, value):
if system == 'ollama':
return value in ('ok', 'warming')
return value == 'ok'
checks = {s: _passes(s, data.get(s)) for s in self.REQUIRED_SYSTEMS}
failing = [s for s, ok in checks.items() if not ok]
if not failing:

View File

@@ -45,6 +45,7 @@ class OdooClient:
self._pg_dsn = pg_dsn
self._pg_pool_min = pg_pool_min
self._pg_pool_max = pg_pool_max
self._timeout = XMLRPC_TIMEOUT
self._uid = None
self._auth_lock = asyncio.Lock()
self._pg_pool = None