feat(odoo): add activeblue_ai Odoo 18 module with OWL2 frontend
Models: - ab.ai.bot: service URL, webhook secret, privacy mode, ping/dispatch - ab.ai.directive: full directive lifecycle log with status tracking - ab.ai.log: activity log with level/agent/record linkage - ab.ai.agent.registry: agent list synced from agent service Controllers: - webhook.py: /ai/webhook/callback handles directive_completed, escalation, sweep_findings - health_proxy.py: /ai/health proxies agent service detailed health - approval.py: /ai/chat dispatch, /ai/approval/pending, /ai/approval/respond Security: - group_ai_user (chat) + group_ai_manager (configure, approve, logs) - ir.model.access.csv for all 4 models Views: list/form for bot, directives, logs, registry; main menu with AI brain icon OWL2 frontend: - systray_button.js: brain icon in top bar, status dot, pending approval badge - ai_panel.js: slide-in chat panel, approval workflow, 30s poll for pending items - CSS: slide-in animation, message bubbles, loading dots, approval section Data: 4 cron jobs (ping, registry sync, directive/log cleanup) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
46
addons/activeblue_ai/models/ab_ai_log.py
Normal file
46
addons/activeblue_ai/models/ab_ai_log.py
Normal file
@@ -0,0 +1,46 @@
|
||||
from odoo import models, fields, api
|
||||
import logging
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class AbAiLog(models.Model):
|
||||
_name = 'ab.ai.log'
|
||||
_description = 'AI Activity Log'
|
||||
_order = 'create_date desc'
|
||||
_rec_name = 'summary'
|
||||
|
||||
summary = fields.Char(string='Summary', required=True, readonly=True)
|
||||
level = fields.Selection(
|
||||
[('info', 'Info'), ('warning', 'Warning'), ('error', 'Error'), ('debug', 'Debug')],
|
||||
string='Level',
|
||||
default='info',
|
||||
required=True,
|
||||
index=True,
|
||||
)
|
||||
agent_name = fields.Char(string='Agent', readonly=True, index=True)
|
||||
directive_id = fields.Char(string='Directive ID', readonly=True, index=True)
|
||||
user_id = fields.Many2one('res.users', string='User', readonly=True)
|
||||
details = fields.Text(string='Details', readonly=True)
|
||||
model_name = fields.Char(string='Model', readonly=True)
|
||||
record_id = fields.Integer(string='Record ID', readonly=True)
|
||||
|
||||
@api.model
|
||||
def log(self, summary, level='info', agent=None, directive_id=None,
|
||||
user_id=None, details=None, model=None, record_id=None):
|
||||
return self.create({
|
||||
'summary': summary[:255] if summary else '',
|
||||
'level': level,
|
||||
'agent_name': agent or '',
|
||||
'directive_id': directive_id or '',
|
||||
'user_id': user_id,
|
||||
'details': details or '',
|
||||
'model_name': model or '',
|
||||
'record_id': record_id or 0,
|
||||
})
|
||||
|
||||
@api.model
|
||||
def cron_cleanup(self):
|
||||
cutoff = fields.Datetime.subtract(fields.Datetime.now(), days=30)
|
||||
old = self.search([('create_date', '<', cutoff), ('level', 'in', ['info', 'debug'])])
|
||||
old.unlink()
|
||||
Reference in New Issue
Block a user