Add timesheet / AI-audit time tracking (wraps account.analytic.line)
- fl.timesheet via delegation inheritance on account.analytic.line so billable hours flow through standard Odoo Accounting; duration_hours maps to unit_amount - Fields: case_id, employee_id, is_billable, ai_agent, duration_hours, computed hourly_rate/billable_amount (rate from hr.employee.fl_hourly_rate, else firm default ir.config_parameter fl_timesheet.default_hourly_rate) - _resolve_analytic_account: prefers the case project's analytic account (version-agnostic field lookup), falls back to a cached firm account under any available analytic plan — handles the required account_id on the wrapped line - Add 'analytic' to manifest depends; ACL for fl.timesheet and account.analytic.line (admin + paralegal) so non-admins can post entries - fl.case: timesheet_ids + total_billable_hours/amount + total_ai_audit_hours + currency_id; new Time & Billing tab; Timesheets menu + standalone views - Both AI agents now log non-billable audit entries via sudo() (paralegal + attorney, ai_agent set); logging stays a guarded no-op if creation fails Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -58,6 +58,7 @@ class FlAttorneyAgent(models.AbstractModel):
|
||||
statutes = self._candidate_statutes(case)
|
||||
caselaw = self._candidate_caselaw(case)
|
||||
|
||||
ai_used = False
|
||||
try:
|
||||
context = self._build_context(case, statutes, caselaw)
|
||||
result = self.env['fl.ai.engine'].call_claude_json(
|
||||
@@ -69,13 +70,31 @@ class FlAttorneyAgent(models.AbstractModel):
|
||||
max_tokens=3000,
|
||||
)
|
||||
self._store_memo(case, analysis, result, statutes, caselaw)
|
||||
ai_used = True
|
||||
except Exception as exc:
|
||||
_logger.error("Attorney agent failed for case %s: %s",
|
||||
case.id, exc, exc_info=True)
|
||||
self._store_fallback(case, analysis, statutes, caselaw, str(exc))
|
||||
|
||||
self._log_ai_time(case, 'Attorney strategy memo', ai_used)
|
||||
return analysis
|
||||
|
||||
def _log_ai_time(self, case, note, ai_used):
|
||||
"""Log a non-billable AI audit entry. No-op until fl.timesheet exists."""
|
||||
if 'fl.timesheet' not in self.env:
|
||||
return
|
||||
try:
|
||||
self.env['fl.timesheet'].sudo().create({
|
||||
'case_id': case.id,
|
||||
'name': note,
|
||||
'is_billable': False,
|
||||
'ai_agent': 'attorney',
|
||||
'duration_hours': 0.1 if ai_used else 0.02,
|
||||
})
|
||||
except Exception as exc: # never block on audit logging
|
||||
_logger.warning("Attorney AI-time logging skipped for case %s: %s",
|
||||
case.id, exc)
|
||||
|
||||
# ──────────────────────────────────────────────────────────────────────
|
||||
# Candidate library (grounds the model in real records)
|
||||
# ──────────────────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user