feat(portal): _fp_group_documents helper for detail-page doc panel

V1 surfaces only the fields directly on fp.portal.job (CoC + packing
list). Other 2 groups (From You, Specifications) render placeholder
rows. V2 will wire in sale.order linking for full doc surfacing.

Also adds _fp_size_label helper for friendly file-size strings.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsinghpal
2026-05-17 02:49:18 -04:00
parent 8c6718e352
commit 4da123c2d3
2 changed files with 114 additions and 0 deletions

View File

@@ -116,3 +116,30 @@ class TestPortalDashboard(TransactionCase):
timeline = FpCustomerPortal()._fp_get_stage_timeline(job)
statuses = [t['status'] for t in timeline]
self.assertEqual(statuses, ['done', 'done', 'done', 'done', 'done'])
def test_group_documents_v1_returns_4_groups(self):
"""V1 doc grouping returns 4 groups; quality populated when CoC set."""
from odoo.addons.fusion_plating_portal.controllers.portal import FpCustomerPortal
Job = self.env['fusion.plating.portal.job']
att = self.env['ir.attachment'].create({
'name': 'CoC_WO-TEST.pdf',
'datas': b'',
'res_model': 'fusion.plating.portal.job',
})
job = Job.create({
'name': 'WO-DOC-001',
'partner_id': self.partner.id,
'state': 'shipped',
'coc_attachment_id': att.id,
})
groups = FpCustomerPortal()._fp_group_documents(job)
self.assertEqual(len(groups), 4)
keys = [g['key'] for g in groups]
self.assertEqual(keys, ['from_you', 'specs', 'quality', 'shipping'])
# Quality group has the CoC populated (not pending)
quality = next(g for g in groups if g['key'] == 'quality')
self.assertTrue(any(d['label'] == 'Certificate of Conformance' and not d.get('pending')
for d in quality['docs']))
# From You + Specifications are placeholders in V1
from_you = next(g for g in groups if g['key'] == 'from_you')
self.assertTrue(all(d.get('pending') for d in from_you['docs']))