changes
This commit is contained in:
@@ -209,59 +209,111 @@ class FusionAccountingDashboard(models.TransientModel):
|
||||
def _compute_action_centre(self):
|
||||
for rec in self:
|
||||
attention = []
|
||||
today = fields.Date.today()
|
||||
|
||||
unrecon = self.env['account.bank.statement.line'].search_count([
|
||||
('is_reconciled', '=', False),
|
||||
('company_id', '=', rec.company_id.id),
|
||||
])
|
||||
if unrecon > 0:
|
||||
attention.append({
|
||||
'priority': 1,
|
||||
'title': f'{unrecon} unreconciled bank lines',
|
||||
'domain': 'bank_reconciliation',
|
||||
'action': 'Review and reconcile bank statement lines',
|
||||
})
|
||||
|
||||
overdue = self.env['account.move'].search_count([
|
||||
('move_type', '=', 'out_invoice'),
|
||||
('state', '=', 'posted'),
|
||||
('payment_state', 'in', ('not_paid', 'partial')),
|
||||
('invoice_date_due', '<', fields.Date.today()),
|
||||
('company_id', '=', rec.company_id.id),
|
||||
])
|
||||
if overdue > 0:
|
||||
attention.append({
|
||||
'priority': 2,
|
||||
'title': f'{overdue} overdue customer invoices',
|
||||
'domain': 'accounts_receivable',
|
||||
'action': 'Send follow-up reminders',
|
||||
})
|
||||
|
||||
# Pending AI approvals (highest priority)
|
||||
pending = self.env['fusion.accounting.match.history'].search_count([
|
||||
('decision', '=', 'pending'),
|
||||
('company_id', '=', rec.company_id.id),
|
||||
])
|
||||
if pending > 0:
|
||||
attention.append({
|
||||
'priority': 0,
|
||||
'title': f'{pending} AI actions awaiting approval',
|
||||
'priority': 0, 'severity': 'danger',
|
||||
'title': f'{pending} AI actions awaiting your approval',
|
||||
'domain': 'audit',
|
||||
'action': 'Review and approve/reject pending actions',
|
||||
'action': 'Review and approve or reject pending actions',
|
||||
'prompt': 'Show me all pending approval actions',
|
||||
})
|
||||
|
||||
# Unreconciled bank lines
|
||||
unrecon = self.env['account.bank.statement.line'].search_count([
|
||||
('is_reconciled', '=', False),
|
||||
('company_id', '=', rec.company_id.id),
|
||||
])
|
||||
if unrecon > 0:
|
||||
attention.append({
|
||||
'priority': 1, 'severity': 'warning',
|
||||
'title': f'{unrecon} unreconciled bank lines',
|
||||
'domain': 'bank_reconciliation',
|
||||
'action': 'Review and reconcile bank statement lines',
|
||||
'prompt': 'Show me unreconciled bank lines across all journals with a breakdown by journal',
|
||||
})
|
||||
|
||||
# Overdue customer invoices
|
||||
overdue = self.env['account.move'].search_count([
|
||||
('move_type', '=', 'out_invoice'),
|
||||
('state', '=', 'posted'),
|
||||
('payment_state', 'in', ('not_paid', 'partial')),
|
||||
('invoice_date_due', '<', today),
|
||||
('company_id', '=', rec.company_id.id),
|
||||
])
|
||||
if overdue > 0:
|
||||
attention.append({
|
||||
'priority': 2, 'severity': 'warning',
|
||||
'title': f'{overdue} overdue customer invoices',
|
||||
'domain': 'accounts_receivable',
|
||||
'action': 'Send follow-up reminders',
|
||||
'prompt': 'Show me overdue invoices sorted by amount',
|
||||
})
|
||||
|
||||
# Unpaid vendor bills due this week
|
||||
week_end = today + timedelta(days=7)
|
||||
due_bills = self.env['account.move'].search_count([
|
||||
('move_type', '=', 'in_invoice'),
|
||||
('state', '=', 'posted'),
|
||||
('payment_state', 'in', ('not_paid', 'partial')),
|
||||
('invoice_date_due', '<=', week_end),
|
||||
('invoice_date_due', '>=', today),
|
||||
('company_id', '=', rec.company_id.id),
|
||||
])
|
||||
if due_bills > 0:
|
||||
attention.append({
|
||||
'priority': 3, 'severity': 'info',
|
||||
'title': f'{due_bills} vendor bills due this week',
|
||||
'domain': 'accounts_payable',
|
||||
'action': 'Review upcoming payments',
|
||||
'prompt': f'Show me vendor bills due between {today} and {week_end}',
|
||||
})
|
||||
|
||||
# Stale draft entries
|
||||
drafts = self.env['account.move'].search_count([
|
||||
('state', '=', 'draft'),
|
||||
('date', '<=', fields.Date.today() - timedelta(days=30)),
|
||||
('date', '<=', today - timedelta(days=30)),
|
||||
('company_id', '=', rec.company_id.id),
|
||||
])
|
||||
if drafts > 0:
|
||||
attention.append({
|
||||
'priority': 3,
|
||||
'priority': 4, 'severity': 'muted',
|
||||
'title': f'{drafts} stale draft entries (30+ days)',
|
||||
'domain': 'journal_review',
|
||||
'action': 'Post or delete stale draft entries',
|
||||
'prompt': 'Find all stale draft entries older than 30 days',
|
||||
})
|
||||
|
||||
# Unmatched customer payments (on outstanding receipts accounts)
|
||||
try:
|
||||
outstanding_accts = self.env['account.account'].search([
|
||||
('name', 'ilike', 'outstanding receipt'),
|
||||
('company_ids', 'in', rec.company_id.id),
|
||||
])
|
||||
if outstanding_accts:
|
||||
unmatched_payments = self.env['account.move.line'].search_count([
|
||||
('account_id', 'in', outstanding_accts.ids),
|
||||
('parent_state', '=', 'posted'),
|
||||
('reconciled', '=', False),
|
||||
('company_id', '=', rec.company_id.id),
|
||||
])
|
||||
if unmatched_payments > 0:
|
||||
attention.append({
|
||||
'priority': 5, 'severity': 'info',
|
||||
'title': f'{unmatched_payments} unmatched customer payments',
|
||||
'domain': 'accounts_receivable',
|
||||
'action': 'Match payments to invoices',
|
||||
'prompt': 'Show me unmatched customer payments that need to be applied to invoices',
|
||||
})
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
attention.sort(key=lambda x: x['priority'])
|
||||
rec.needs_attention_json = json.dumps(attention)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user