feat(portal): welcome-line summary counts on /my/home + tests
Adds active_job_count, awaiting_review_count, ready_to_ship_count to the dashboard context. Tests verify partition is correct across the fp.portal.job and fp.quote.request state machines. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -185,6 +185,20 @@ class FpCustomerPortal(CustomerPortal):
|
|||||||
)
|
)
|
||||||
invoice_count = Invoice.search_count(invoice_domain)
|
invoice_count = Invoice.search_count(invoice_domain)
|
||||||
|
|
||||||
|
# Welcome-line summary counts (jobs-forward dashboard).
|
||||||
|
active_job_count = Job.search_count([
|
||||||
|
('partner_id', 'child_of', commercial.id),
|
||||||
|
('state', 'in', ['received', 'in_progress', 'quality_check']),
|
||||||
|
])
|
||||||
|
awaiting_review_count = Quote.search_count([
|
||||||
|
('partner_id', 'child_of', commercial.id),
|
||||||
|
('state', '=', 'quoted'),
|
||||||
|
])
|
||||||
|
ready_to_ship_count = Job.search_count([
|
||||||
|
('partner_id', 'child_of', commercial.id),
|
||||||
|
('state', '=', 'ready_to_ship'),
|
||||||
|
])
|
||||||
|
|
||||||
values = {
|
values = {
|
||||||
'page_name': 'fp_dashboard',
|
'page_name': 'fp_dashboard',
|
||||||
'partner': partner,
|
'partner': partner,
|
||||||
@@ -206,6 +220,10 @@ class FpCustomerPortal(CustomerPortal):
|
|||||||
# Invoices
|
# Invoices
|
||||||
'recent_invoices': recent_invoices,
|
'recent_invoices': recent_invoices,
|
||||||
'invoice_count': invoice_count,
|
'invoice_count': invoice_count,
|
||||||
|
# Welcome-line summary
|
||||||
|
'active_job_count': active_job_count,
|
||||||
|
'awaiting_review_count': awaiting_review_count,
|
||||||
|
'ready_to_ship_count': ready_to_ship_count,
|
||||||
}
|
}
|
||||||
return request.render(
|
return request.render(
|
||||||
'fusion_plating_portal.fp_portal_home_dashboard',
|
'fusion_plating_portal.fp_portal_home_dashboard',
|
||||||
|
|||||||
1
fusion_plating/fusion_plating_portal/tests/__init__.py
Normal file
1
fusion_plating/fusion_plating_portal/tests/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import test_portal_dashboard
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright 2026 Nexa Systems Inc.
|
||||||
|
# License OPL-1.
|
||||||
|
|
||||||
|
from odoo.tests import TransactionCase, tagged
|
||||||
|
|
||||||
|
|
||||||
|
@tagged('post_install', '-at_install', 'fp_portal')
|
||||||
|
class TestPortalDashboard(TransactionCase):
|
||||||
|
"""Welcome-line summary counts for the redesigned /my/home."""
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
super().setUpClass()
|
||||||
|
cls.partner = cls.env['res.partner'].create({
|
||||||
|
'name': 'Test Customer Co.',
|
||||||
|
'email': 'test@example.com',
|
||||||
|
})
|
||||||
|
cls.portal_user = cls.env['res.users'].create({
|
||||||
|
'name': 'Portal Tester',
|
||||||
|
'login': 'portal_tester',
|
||||||
|
'partner_id': cls.partner.id,
|
||||||
|
'group_ids': [(6, 0, [cls.env.ref('base.group_portal').id])],
|
||||||
|
})
|
||||||
|
Job = cls.env['fusion.plating.portal.job']
|
||||||
|
# 2 active, 1 ready_to_ship, 1 shipped (should not count as active)
|
||||||
|
cls.job_received = Job.create({
|
||||||
|
'name': 'WO-TEST-001', 'partner_id': cls.partner.id, 'state': 'received'})
|
||||||
|
cls.job_in_progress = Job.create({
|
||||||
|
'name': 'WO-TEST-002', 'partner_id': cls.partner.id, 'state': 'in_progress'})
|
||||||
|
cls.job_ready = Job.create({
|
||||||
|
'name': 'WO-TEST-003', 'partner_id': cls.partner.id, 'state': 'ready_to_ship'})
|
||||||
|
cls.job_shipped = Job.create({
|
||||||
|
'name': 'WO-TEST-004', 'partner_id': cls.partner.id, 'state': 'shipped'})
|
||||||
|
# 1 quoted RFQ (counts as awaiting_review), 1 new (does not count)
|
||||||
|
Quote = cls.env['fusion.plating.quote.request']
|
||||||
|
cls.quote_quoted = Quote.create({
|
||||||
|
'name': 'QR-TEST-001', 'partner_id': cls.partner.id, 'state': 'quoted'})
|
||||||
|
cls.quote_new = Quote.create({
|
||||||
|
'name': 'QR-TEST-002', 'partner_id': cls.partner.id, 'state': 'new'})
|
||||||
|
|
||||||
|
def test_welcome_counts_separates_active_from_ready_from_review(self):
|
||||||
|
"""The 3 welcome-line numbers split correctly across states."""
|
||||||
|
commercial = self.partner.commercial_partner_id
|
||||||
|
active = self.env['fusion.plating.portal.job'].search_count([
|
||||||
|
('partner_id', 'child_of', commercial.id),
|
||||||
|
('state', 'in', ['received', 'in_progress', 'quality_check']),
|
||||||
|
])
|
||||||
|
awaiting_review = self.env['fusion.plating.quote.request'].search_count([
|
||||||
|
('partner_id', 'child_of', commercial.id),
|
||||||
|
('state', '=', 'quoted'),
|
||||||
|
])
|
||||||
|
ready_to_ship = self.env['fusion.plating.portal.job'].search_count([
|
||||||
|
('partner_id', 'child_of', commercial.id),
|
||||||
|
('state', '=', 'ready_to_ship'),
|
||||||
|
])
|
||||||
|
self.assertEqual(active, 2)
|
||||||
|
self.assertEqual(awaiting_review, 1)
|
||||||
|
self.assertEqual(ready_to_ship, 1)
|
||||||
Reference in New Issue
Block a user